forked from rstackjs/rstack-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathargs.test.ts
More file actions
39 lines (33 loc) · 996 Bytes
/
Copy pathargs.test.ts
File metadata and controls
39 lines (33 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { expect, test } from 'rstack/test';
import { parseArgs } from '../../src/cli/args.ts';
test.each([
['--long-option', 'kebab'],
['--longOption', 'camel'],
] as const)('accepts %s and returns only a camel-case value', (option, value) => {
const { values } = parseArgs({
args: [option, value],
options: {
'long-option': { type: 'string' },
},
});
expect(values).toEqual({ longOption: value });
expect('long-option' in values).toBe(false);
});
test('combines repeated kebab-case and camel-case values', () => {
const { values } = parseArgs({
args: ['--include-path', 'first', '--includePath', 'second'],
options: {
'include-path': { type: 'string', multiple: true },
},
});
expect(values).toEqual({ includePath: ['first', 'second'] });
});
test('omits undefined values', () => {
const { values } = parseArgs({
args: [],
options: {
'optional-value': { type: 'string' },
},
});
expect(values).toEqual({});
});