-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (35 loc) · 1.13 KB
/
Copy pathindex.ts
File metadata and controls
43 lines (35 loc) · 1.13 KB
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
40
41
42
43
import { test, expect } from 'manten';
import { flagNameToKebab, typeFlag } from '#type-flag';
test('standard camelCase', () => {
expect(flagNameToKebab('fooBar')).toBe('foo-bar');
});
test('trailing acronym', () => {
expect(flagNameToKebab('orgID')).toBe('org-id');
expect(flagNameToKebab('apiURL')).toBe('api-url');
});
test('middle acronym followed by capitalized word', () => {
expect(flagNameToKebab('someAPIKey')).toBe('some-api-key');
});
test('middle acronym before capitalized word', () => {
expect(flagNameToKebab('parseJSONData')).toBe('parse-json-data');
});
test('all-caps standalone', () => {
expect(flagNameToKebab('ID')).toBe('id');
});
test('already lowercase', () => {
expect(flagNameToKebab('id')).toBe('id');
});
test('single word', () => {
expect(flagNameToKebab('simple')).toBe('simple');
});
test('parses acronym flag names from argv', () => {
const parsed = typeFlag({
orgID: String,
apiURL: String,
}, [
'--org-id=acme',
'--api-url=https://example.com',
]);
expect<string | undefined>(parsed.flags.orgID).toBe('acme');
expect<string | undefined>(parsed.flags.apiURL).toBe('https://example.com');
});