Skip to content

Commit

Permalink
Fixing test to use test cases rather than using string tagged templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ofiriro3 committed Dec 26, 2022
1 parent 1af5bdc commit ca37e64
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
11 changes: 0 additions & 11 deletions x-pack/plugins/cloud_security_posture/common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,3 @@ export function assert(condition: any, msg?: string): asserts condition {
throw new Error(msg);
}
}

export const createCspRuleSearchFilterByPackagePolicy = ({
packagePolicyId,
policyId,
}: {
packagePolicyId: string;
policyId?: string;
}): string =>
`${CSP_RULE_SAVED_OBJECT_TYPE}.attributes.package_policy_id: "${packagePolicyId}"${
policyId ? ` AND ${CSP_RULE_SAVED_OBJECT_TYPE}.attributes.policy_id: "${policyId}"` : ''
}`;
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ describe('is Csp package installed tests', () => {
const packagePolicyService = createPackagePolicyServiceMock();

beforeEach(() => jest.clearAllMocks());
it.each`
total | items | expectedCspPolicyResponse
${1} | ${[createPackagePolicyMock()]} | ${true}
${0} | ${[]} | ${false}
`(
it.each([
[1, [createPackagePolicyMock()], true],
[0, [], false],
])(
'isCspPackagePolicyInstalled should return true when other packages exist',
async ({ total, items, expectedCspPolicyResponse }) => {
async (total, items, expectedCspPolicyResponse) => {
packagePolicyService.list.mockImplementationOnce(
async (): Promise<ListResult<PackagePolicy>> => {
return {
Expand Down
11 changes: 5 additions & 6 deletions x-pack/plugins/cloud_security_posture/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,12 @@ describe('Cloud Security Posture Plugin', () => {
expect(fleetMock.packagePolicyService.update).toHaveBeenCalledTimes(0);
});

it.each`
total | items | expectedNumberOfCallsToUninstallResources
${1} | ${[createPackagePolicyMock()]} | ${0}
${0} | ${[]} | ${1}
`(
it.each([
[1, [createPackagePolicyMock()], 0],
[0, [], 1],
])(
'should uninstall resources when package is removed',
async ({ total, items, expectedNumberOfCallsToUninstallResources }) => {
async (total, items, expectedNumberOfCallsToUninstallResources) => {
fleetMock.packagePolicyService.list.mockImplementationOnce(
async (): Promise<ListResult<PackagePolicy>> => {
return {
Expand Down

0 comments on commit ca37e64

Please sign in to comment.