Skip to content

Commit

Permalink
test: add test for short-option followed by its value
Browse files Browse the repository at this point in the history
PR-URL: #43358
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cola119 authored and danielleadams committed Jun 13, 2022
1 parent f8d26c6 commit e1b8c85
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/parallel/test-parse-args.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ test('handles short-option groups with "short" alias configured', () => {
assert.deepStrictEqual(result, expected);
});

test('handles short-option followed by its value', () => {
const args = ['-fFILE'];
const options = { foo: { short: 'f', type: 'string' } };
const expected = { values: { __proto__: null, foo: 'FILE' }, positionals: [] };
const result = parseArgs({ strict: false, args, options });
assert.deepStrictEqual(result, expected);
});

test('Everything after a bare `--` is considered a positional argument', () => {
const args = ['--', 'barepositionals', 'mopositionals'];
const expected = { values: { __proto__: null }, positionals: ['barepositionals', 'mopositionals'] };
Expand Down

0 comments on commit e1b8c85

Please sign in to comment.