Skip to content

Commit

Permalink
test(util): tune command assertions in npm
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Dec 5, 2024
1 parent a609666 commit 5ff51af
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/__tests__/if-check/util/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ jest.mock('../../../common/util/logger', () => ({
},
}));

jest.mock('../../../common/util/helpers', () => {
const originalModule = jest.requireActual('../../../common/util/helpers');
jest.mock('child_process', () => {
const originalModule = jest.requireActual('child_process');
return {
...originalModule,
execPromise: async (param: any) => {
execFileSync: (file: any, args: any) => {
switch (process.env.NPM_INSTALL) {
case 'true':
expect(param).toEqual('npm install @grnsft/[email protected]');
expect(file).toEqual('npm install @grnsft/[email protected]');
break;
case 'npm init -y':
expect(param).toEqual('npm init -y');
expect(file).toEqual('npm init -y');
break;
case 'if-check':
expect(
[
'npm run if-env -- -m ./src/__mocks__/mock-manifest.yaml',
'npm run if-run -- -m ./src/__mocks__/mock-manifest.yaml -o src/__mocks__/re-mock-manifest',
"node -p 'Boolean(process.stdout.isTTY)'",
'node -p Boolean(process.stdout.isTTY)',
'npm run if-diff -- -s src/__mocks__/re-mock-manifest.yaml -t ./src/__mocks__/mock-manifest.yaml',
].includes(param)
].includes(`${file} ${args.join(' ')}`)
).toBeTruthy();
break;
}
Expand All @@ -50,7 +50,7 @@ describe('if-check/util/npm: ', () => {

await executeCommands(manifest, false);

expect.assertions(5);
expect.assertions(6);
expect(logSpy).toHaveBeenCalledWith(
'✔ if-check successfully verified mock-manifest.yaml\n'
);
Expand Down

0 comments on commit 5ff51af

Please sign in to comment.