test: add test for short-option followed by its value

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Kohei Ueno authored and Michaël Zasso committed 2022-07-31 15:34:48 +02:00
1 parent 2b498fe7f5
commit b5eb55646f
1 file changed
+8
+8
View File
@@ -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'] };