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

Add regression test for -no- handling #1304

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/options.bool.test.js
Expand Up @@ -107,3 +107,22 @@ describe('boolean flag with non-boolean default', () => {
expect(program.olives).toBe(flagValue);
});
});

// Regression test for #1301 with `-no-` in middle of option
describe('regression test for -no- in middle of option flag', () => {
test('when flag not specified then value is undefined', () => {
const program = new commander.Command();
program
.option('--module-no-parse');
program.parse(['node', 'test']);
expect(program.moduleNoParse).toBeUndefined();
});

test('when flag specified then value is true', () => {
const program = new commander.Command();
program
.option('--module-no-parse');
program.parse(['node', 'test', '--module-no-parse']);
expect(program.moduleNoParse).toEqual(true);
});
});