Skip to content

Commit

Permalink
fix jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Aug 27, 2024
1 parent 4c34803 commit daa3308
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@

import { savedObjectsClientMock } from '@kbn/core/server/mocks';

import type { SavedObject } from '@kbn/core-saved-objects-common';

import type { Installation, PackageInfo } from '../../types';
import { getPackageInfo, getInstallation } from '../epm/packages';
import { getPackageInfo, getInstallationObject } from '../epm/packages';

import { getMonitoringPermissions } from './monitoring_permissions';

jest.mock('../epm/packages');

const mockedGetInstallation = getInstallation as jest.Mock<ReturnType<typeof getInstallation>>;
const mockedGetInstallation = getInstallationObject as jest.Mock<
ReturnType<typeof getInstallationObject>
>;
const mockedGetPackageInfo = getPackageInfo as jest.Mock<ReturnType<typeof getPackageInfo>>;

describe('getMonitoringPermissions', () => {
Expand Down Expand Up @@ -66,9 +70,11 @@ describe('getMonitoringPermissions', () => {
beforeEach(() => {
// Mock a simplified elastic agent package with only 4 datastreams logs and metrics for filebeat and metricbeat
mockedGetInstallation.mockResolvedValue({
name: 'elastic_agent',
version: '1.0.0',
} as Installation);
attributes: {
name: 'elastic_agent',
version: '1.0.0',
},
} as SavedObject<Installation>);
mockedGetPackageInfo.mockResolvedValue({
data_streams: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('SyntheticsPrivateLocation', () => {
'check.request.method': 'GET',
username: '',
} as unknown as HeartbeatConfig;
const mockBuildPackagePolicy = jest.fn().mockReturnValue(undefined);
const mockBuildPackagePolicy = jest.fn().mockReturnValue({});

const serverMock: SyntheticsServerSetup = {
syntheticsEsClient: { search: jest.fn() },
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('SyntheticsPrivateLocation', () => {
},
} as unknown as SyntheticsServerSetup;
beforeEach(() => {
mockBuildPackagePolicy.mockReturnValue(undefined);
mockBuildPackagePolicy.mockReturnValue({});
});

describe('getPolicyNamespace', () => {
Expand Down

0 comments on commit daa3308

Please sign in to comment.