Skip to content

Commit b7d7b12

Browse files
authored
test: add test for multiple+boolean (#93)
1 parent ba4815e commit b7d7b12

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,22 @@ test('args are passed `type: "string"` and "multiple"', function(t) {
233233
t.end();
234234
});
235235

236+
test('when expecting `multiple:true` boolean option and option used multiple times then result includes array of booleans matching usage', function(t) {
237+
const passedArgs = ['--foo', '--foo'];
238+
const passedOptions = {
239+
foo: {
240+
type: 'boolean',
241+
multiple: true,
242+
},
243+
};
244+
const expected = { flags: { foo: true }, values: { foo: [true, true] }, positionals: [] };
245+
const args = parseArgs({ args: passedArgs, options: passedOptions });
246+
247+
t.deepEqual(args, expected);
248+
249+
t.end();
250+
});
251+
236252
test('order of option and positional does not matter (per README)', function(t) {
237253
const passedArgs1 = ['--foo=bar', 'baz'];
238254
const passedArgs2 = ['baz', '--foo=bar'];

0 commit comments

Comments
 (0)