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: always store value for a=b #43

Merged
merged 5 commits into from
Feb 4, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'main' into feature/fix-equals, fix tests
  • Loading branch information
shadowspawn committed Jan 24, 2022
commit 445c42fd2014ba7a3a30c9cefc8c8c706511c2c2
15 changes: 13 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test('args equals are passed "withValue"', function(t) {
test('zero config args equals are parsed as if "withValue"', function(t) {
const passedArgs = ['--so=wat'];
const passedOptions = { };
const expected = { flags: { so: true }, values: { so: ['wat'] }, positionals: [] };
const expected = { flags: { so: true }, values: { so: 'wat' }, positionals: [] };
const args = parseArgs(passedArgs, passedOptions);

t.deepEqual(args, expected, 'arg value is passed');
Expand All @@ -72,14 +72,25 @@ test('same arg is passed twice "withValue" and last value is recorded', function
test('args equals pass string including more equals', function(t) {
const passedArgs = ['--so=wat=bing'];
const passedOptions = { withValue: ['so'] };
const expected = { flags: { so: true }, values: { so: ['wat=bing'] }, positionals: [] };
const expected = { flags: { so: true }, values: { so: 'wat=bing' }, positionals: [] };
const args = parseArgs(passedArgs, passedOptions);

t.deepEqual(args, expected, 'arg value is passed');

t.end();
});

test('first arg passed for "withValue" and "multiples" is in array', function(t) {
const passedArgs = ['--foo=a'];
const passedOptions = { withValue: ['foo'], multiples: ['foo'] };
const expected = { flags: { foo: true }, values: { foo: ['a'] }, positionals: [] };
const args = parseArgs(passedArgs, passedOptions);

t.deepEqual(args, expected, 'first multiple in array');

t.end();
});

test('args are passed "withValue" and "multiples"', function(t) {
const passedArgs = ['--foo=a', '--foo', 'b'];
const passedOptions = { withValue: ['foo'], multiples: ['foo'] };
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.