-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
nomalize-options.spec.ts
130 lines (125 loc) · 3.67 KB
/
nomalize-options.spec.ts
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { Linter } from '@nrwl/linter';
import { Schema } from '../schema';
import { normalizeOptions } from './normalize-options';
describe('Normalize Options', () => {
it('should normalize options with name in kebab case', () => {
const schema: Schema = {
name: 'my-app',
linter: Linter.EsLint,
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
androidProjectRoot: 'apps/my-app/android',
appProjectRoot: 'apps/my-app',
className: 'MyApp',
displayName: 'MyApp',
iosProjectRoot: 'apps/my-app/ios',
lowerCaseName: 'myapp',
name: 'my-app',
parsedTags: [],
projectName: 'my-app',
linter: Linter.EsLint,
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});
it('should normalize options with name in camel case', () => {
const schema: Schema = {
name: 'myApp',
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
androidProjectRoot: 'apps/my-app/android',
appProjectRoot: 'apps/my-app',
className: 'MyApp',
displayName: 'MyApp',
iosProjectRoot: 'apps/my-app/ios',
lowerCaseName: 'myapp',
name: 'my-app',
parsedTags: [],
projectName: 'my-app',
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});
it('should normalize options with directory', () => {
const schema: Schema = {
name: 'my-app',
directory: 'directory',
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
androidProjectRoot: 'apps/directory/my-app/android',
appProjectRoot: 'apps/directory/my-app',
className: 'MyApp',
displayName: 'MyApp',
iosProjectRoot: 'apps/directory/my-app/ios',
lowerCaseName: 'myapp',
name: 'my-app',
directory: 'directory',
parsedTags: [],
projectName: 'directory-my-app',
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});
it('should normalize options that has directory in its name', () => {
const schema: Schema = {
name: 'directory/my-app',
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
androidProjectRoot: 'apps/directory/my-app/android',
appProjectRoot: 'apps/directory/my-app',
className: 'DirectoryMyApp',
displayName: 'DirectoryMyApp',
iosProjectRoot: 'apps/directory/my-app/ios',
lowerCaseName: 'directorymyapp',
name: 'directory/my-app',
parsedTags: [],
projectName: 'directory-my-app',
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});
it('should normalize options with display name', () => {
const schema: Schema = {
name: 'my-app',
displayName: 'My App',
e2eTestRunner: 'none',
install: false,
};
const options = normalizeOptions(schema);
expect(options).toEqual({
androidProjectRoot: 'apps/my-app/android',
appProjectRoot: 'apps/my-app',
className: 'MyApp',
displayName: 'My App',
iosProjectRoot: 'apps/my-app/ios',
lowerCaseName: 'myapp',
name: 'my-app',
parsedTags: [],
projectName: 'my-app',
entryFile: 'src/main.tsx',
e2eTestRunner: 'none',
unitTestRunner: 'jest',
install: false,
});
});
});