From 35b1aa9a7a17b246f8508a2b89e9eaa143824581 Mon Sep 17 00:00:00 2001 From: Eric Willhoit Date: Wed, 12 Oct 2022 13:14:58 -0500 Subject: [PATCH] fix: parse varargs response type --- src/util.ts | 4 ++-- test/unit/util.test.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/util.ts b/src/util.ts index 7769fb47..8ee91931 100644 --- a/src/util.ts +++ b/src/util.ts @@ -62,8 +62,8 @@ export function toHelpSection( return { header, body }; } -export function parseVarArgs(args: Record, argv: string[]): Record { - const final: Record = {}; +export function parseVarArgs(args: Record, argv: string[]): Record { + const final: Record = {}; const argVals = Object.values(args); // Remove arguments from varargs diff --git a/test/unit/util.test.ts b/test/unit/util.test.ts index 95e163c9..02f0a539 100644 --- a/test/unit/util.test.ts +++ b/test/unit/util.test.ts @@ -93,6 +93,16 @@ describe('parseVarArgs', () => { expect(varargs).to.deep.equal({ key1: 'value1' }); }); + it('should parse multiple varargs', () => { + const varargs = parseVarArgs({}, ['key1=value1', 'key2=value2']); + expect(varargs).to.deep.equal({ key1: 'value1', key2: 'value2' }); + }); + + it('should allow an empty value', () => { + const varargs = parseVarArgs({}, ['key1=']); + expect(varargs).to.deep.equal({ key1: undefined }); + }); + it('should parse varargs and not arguments', () => { const varargs = parseVarArgs({ arg1: 'foobar' }, ['foobar', 'key1=value1']); expect(varargs).to.deep.equal({ key1: 'value1' });