Skip to content

Commit cd507e2

Browse files
committed
Add tests for default parseArgs configuration options
1 parent 94a29b1 commit cd507e2

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

test/registry/parse-args.test.mts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,4 +391,52 @@ describe('parse-args module', () => {
391391
expect(result.values['downloadOnly']).toBe(true)
392392
})
393393
})
394+
395+
describe('default configuration options', () => {
396+
it('should allow short option groups by default', () => {
397+
const result = parseArgs({
398+
args: ['-vdf'],
399+
options: {
400+
verbose: { type: 'boolean', short: 'v' },
401+
debug: { type: 'boolean', short: 'd' },
402+
force: { type: 'boolean', short: 'f' },
403+
},
404+
})
405+
expect(result.values['verbose']).toBe(true)
406+
expect(result.values['debug']).toBe(true)
407+
expect(result.values['force']).toBe(true)
408+
})
409+
410+
it('should handle duplicate arguments as arrays', () => {
411+
const result = parseArgs({
412+
args: ['--tag', 'v1', '--tag', 'v2', '--tag', 'v3'],
413+
options: {
414+
tag: { type: 'string', multiple: true },
415+
},
416+
})
417+
expect(result.values['tag']).toEqual(['v1', 'v2', 'v3'])
418+
})
419+
420+
it('should populate arguments after -- separator', () => {
421+
const result = parseArgs({
422+
args: ['--verbose', '--', 'arg1', 'arg2'],
423+
options: {
424+
verbose: { type: 'boolean' },
425+
},
426+
})
427+
expect(result.values['verbose']).toBe(true)
428+
expect(result.raw['--']).toEqual(['arg1', 'arg2'])
429+
})
430+
431+
it('should not parse dot notation by default', () => {
432+
const result = parseArgs({
433+
args: ['--config.port', '8080'],
434+
options: {
435+
'config.port': { type: 'string' },
436+
},
437+
})
438+
expect(result.values['config.port']).toBe('8080')
439+
expect(result.values['config']).toBeUndefined()
440+
})
441+
})
394442
})

0 commit comments

Comments
 (0)