Skip to content

Commit

Permalink
chore: adds debug param acceptance test (#4453)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luong authored Mar 9, 2023
1 parent 3696905 commit 2759917
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cli/commands/woof/getWoof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const woofs = {
cs: ' Haf!',
uk: ' Гав!',
de: 'Wuff!',
cat: 'Meow?',
};

export default function getWoof(args: MethodArgs): string {
Expand All @@ -21,5 +22,11 @@ export default function getWoof(args: MethodArgs): string {
lang = options.language;
}

if (lang === 'cat') {
for (const option in options) {
console.debug(`${option}:::`, options[option], `:::${option}`);
}
}

return woofs[lang];
}
15 changes: 15 additions & 0 deletions test/jest/acceptance/cli-args.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ describe('cli args', () => {
});
});

test('delimiting args should pass expected args to the command as expected', async () => {
const { stdout } = await runSnykCLI(
`-d woof --language=cat -- --hello --world`,
{
env,
},
);
const doubleDashArgsStart = stdout.indexOf('_doubleDashArgs:::');
const doubleDashArgsEnd = stdout.indexOf(':::_doubleDashArgs');
const doubleDashArgs = stdout.slice(doubleDashArgsStart, doubleDashArgsEnd);
expect(doubleDashArgs).toStrictEqual(
"_doubleDashArgs::: [ '--hello', '--world' ] ",
);
});

test('snyk test command should fail when --file is not specified correctly', async () => {
const { code, stdout } = await runSnykCLI(`test --file package-lock.json`, {
env,
Expand Down

0 comments on commit 2759917

Please sign in to comment.