From 6a9a9523a9bf970446efad1ac9a7a8304b51ec5f Mon Sep 17 00:00:00 2001 From: Kohei Ueno Date: Sun, 12 Jun 2022 18:41:50 +0900 Subject: [PATCH] test: add test for short-option followed by its value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/43358 Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen Reviewed-By: Beth Griggs Reviewed-By: Colin Ihrig Reviewed-By: Darshan Sen Reviewed-By: Akhil Marsonya Reviewed-By: James M Snell --- test/parallel/test-parse-args.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/parallel/test-parse-args.mjs b/test/parallel/test-parse-args.mjs index 602ab1fc97ea4b..ef0ac006282bd7 100644 --- a/test/parallel/test-parse-args.mjs +++ b/test/parallel/test-parse-args.mjs @@ -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'] };