Skip to content

Commit

Permalink
Fix jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-tavares committed Jul 10, 2023
1 parent 199790b commit 038bc2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type { AppContextTestRender } from '../../../../../../common/mock/endpoin
import { EndpointPolicyEditExtension } from './endpoint_policy_edit_extension';
import { createFleetContextRendererMock } from '../mocks';
import { getUserPrivilegesMockDefaultValue } from '../../../../../../common/components/user_privileges/__mocks__';
import { FleetPackagePolicyGenerator } from '../../../../../../../common/endpoint/data_generators/fleet_package_policy_generator';
import { getPolicyDataForUpdate } from '../../../../../../../common/endpoint/service/policy';

jest.mock('../../../../../../common/components/user_privileges');
const useUserPrivilegesMock = useUserPrivileges as jest.Mock;
Expand All @@ -29,12 +31,16 @@ describe('When displaying the EndpointPolicyEditExtension fleet UI extension', (

beforeEach(() => {
const mockedTestContext = createFleetContextRendererMock();
const policy = new FleetPackagePolicyGenerator('seed').generateEndpointPackagePolicy({
id: 'someid',
});
const newPolicy = getPolicyDataForUpdate(policy);

render = () =>
mockedTestContext.render(
<EndpointPolicyEditExtension
policy={{ id: 'someid' } as PackagePolicy}
newPolicy={{ id: 'someid' } as NewPackagePolicy}
policy={policy as PackagePolicy}
newPolicy={newPolicy as NewPackagePolicy}
onChange={jest.fn()}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ import { policyListApiPathHandlers } from '../store/test_mock_utils';
import { PolicyDetails } from './policy_details';
import { APP_UI_ID } from '../../../../../common/constants';

jest.mock('./policy_forms/components/policy_form_layout', () => ({
PolicyFormLayout: () => <></>,
}));
jest.mock('../../../../common/components/user_privileges');

const useUserPrivilegesMock = useUserPrivileges as jest.Mock;
Expand Down

0 comments on commit 038bc2c

Please sign in to comment.