Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix if-check npm tests after merge #1092

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions src/__tests__/if-check/util/npm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,6 @@ jest.mock('child_process', () => {
)
).toBeTruthy();
break;
case 'if-check-cwd':
expect(param).toEqual(
"npm run if-env -- -m ./src/__mocks__/mock-manifest.yaml -c && npm run if-run -- -m ./src/__mocks__/mock-manifest.yaml -o src/__mocks__/re-mock-manifest && node -p 'Boolean(process.stdout.isTTY)' | npm run if-diff -- -s src/__mocks__/re-mock-manifest.yaml -t ./src/__mocks__/mock-manifest.yaml"
);
break;
case 'if-check-global':
expect(param).toEqual(
"if-env -m ./src/__mocks__/mock-manifest.yaml && if-run -m ./src/__mocks__/mock-manifest.yaml -o src/__mocks__/re-mock-manifest && node -p 'Boolean(process.stdout.isTTY)' | if-diff -s src/__mocks__/re-mock-manifest.yaml -t ./src/__mocks__/mock-manifest.yaml"
);
break;
case 'if-check-prefix':
expect(param).toEqual(
"if-env --prefix=.. -m ./src/__mocks__/mock-manifest.yaml && if-run --prefix=.. -m ./src/__mocks__/mock-manifest.yaml -o src/__mocks__/re-mock-manifest && node -p 'Boolean(process.stdout.isTTY)' | if-diff --prefix=.. -s src/__mocks__/re-mock-manifest.yaml -t ./src/__mocks__/mock-manifest.yaml"
);
break;
}
return;
},
Expand All @@ -72,47 +57,5 @@ describe('if-check/util/npm: ', () => {
'✔ if-check successfully verified mock-manifest.yaml\n'
);
});

it('successfully executes with cwd command.', async () => {
process.env.NPM_INSTALL = 'if-check-cwd';
const manifest = './src/__mocks__/mock-manifest.yaml';
const logSpy = jest.spyOn(global.console, 'log');

await executeCommands(manifest, true);

expect.assertions(2);
expect(logSpy).toHaveBeenCalledWith(
'✔ if-check successfully verified mock-manifest.yaml\n'
);
});

it('successfully executes with correct commands when is running from global.', async () => {
process.env.npm_config_global = 'true';
process.env.NPM_INSTALL = 'if-check-global';
const manifest = './src/__mocks__/mock-manifest.yaml';
const logSpy = jest.spyOn(global.console, 'log');

await executeCommands(manifest, false);

expect.assertions(2);
expect(logSpy).toHaveBeenCalledWith(
'✔ if-check successfully verified mock-manifest.yaml\n'
);
});

it('successfully executes with correct commands when CURRENT_DIR is provided.', async () => {
process.env.CURRENT_DIR = './mock-path';
process.env.npm_config_global = 'true';
process.env.NPM_INSTALL = 'if-check-prefix';
const manifest = './src/__mocks__/mock-manifest.yaml';
const logSpy = jest.spyOn(global.console, 'log');

await executeCommands(manifest, false);

expect.assertions(2);
expect(logSpy).toHaveBeenCalledWith(
'✔ if-check successfully verified mock-manifest.yaml\n'
);
});
});
});
Loading