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' });