Skip to content

Commit 7a22bde

Browse files
committed
Add tests for kebab-case to camelCase conversion in parseArgs
1 parent 4b71e20 commit 7a22bde

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

test/registry/parse-args.test.mts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,53 @@ describe('parse-args module', () => {
342342
expect(typeof result.values['port']).toBe('number')
343343
})
344344
})
345+
346+
describe('camelCase conversion', () => {
347+
it('should convert kebab-case options to camelCase', () => {
348+
const result = parseArgs({
349+
args: ['--temp-dir', '/tmp/test'],
350+
options: {
351+
'temp-dir': { type: 'string' },
352+
},
353+
})
354+
expect(result.values['temp-dir']).toBe('/tmp/test')
355+
expect(result.values['tempDir']).toBe('/tmp/test')
356+
})
357+
358+
it('should convert multi-segment kebab-case to camelCase', () => {
359+
const result = parseArgs({
360+
args: ['--download-concurrency', '10'],
361+
options: {
362+
'download-concurrency': { type: 'string' },
363+
},
364+
})
365+
expect(result.values['download-concurrency']).toBe('10')
366+
expect(result.values['downloadConcurrency']).toBe('10')
367+
})
368+
369+
it('should handle boolean kebab-case options', () => {
370+
const result = parseArgs({
371+
args: ['--clear-cache'],
372+
options: {
373+
'clear-cache': { type: 'boolean' },
374+
},
375+
})
376+
expect(result.values['clear-cache']).toBe(true)
377+
expect(result.values['clearCache']).toBe(true)
378+
})
379+
380+
it('should handle multiple kebab-case options', () => {
381+
const result = parseArgs({
382+
args: ['--temp-dir', '/tmp', '--clear-cache', '--download-only'],
383+
options: {
384+
'temp-dir': { type: 'string' },
385+
'clear-cache': { type: 'boolean' },
386+
'download-only': { type: 'boolean' },
387+
},
388+
})
389+
expect(result.values['tempDir']).toBe('/tmp')
390+
expect(result.values['clearCache']).toBe(true)
391+
expect(result.values['downloadOnly']).toBe(true)
392+
})
393+
})
345394
})

0 commit comments

Comments
 (0)