Skip to content

Commit b190e51

Browse files
test: camelCase option (#814)
1 parent 0bdf9b7 commit b190e51

File tree

4 files changed

+323
-80
lines changed

4 files changed

+323
-80
lines changed
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`camelCase option dashes: errors 1`] = `Array []`;
4+
5+
exports[`camelCase option dashes: locals 1`] = `
6+
Object {
7+
"btn--info_is-disabled_1": "jDvNwV-WRSMB9n2z9QrzR",
8+
"btn-info_is-disabled": "_1XTfjK5gKYeSzbdZhEXRpF",
9+
"btnInfo_isDisabled": "_1XTfjK5gKYeSzbdZhEXRpF",
10+
"btnInfo_isDisabled_1": "jDvNwV-WRSMB9n2z9QrzR",
11+
"foo": "bar",
12+
"my-btn-info_is-disabled": "value",
13+
"myBtnInfo_isDisabled": "value",
14+
"simple": "_1penVf9PMtov2qLxmtsMjq",
15+
}
16+
`;
17+
18+
exports[`camelCase option dashes: module (evaluated) 1`] = `
19+
Array [
20+
Array [
21+
1,
22+
"._1XTfjK5gKYeSzbdZhEXRpF {
23+
color: blue;
24+
}
25+
26+
.jDvNwV-WRSMB9n2z9QrzR {
27+
color: blue;
28+
}
29+
30+
._1penVf9PMtov2qLxmtsMjq {
31+
color: red;
32+
}
33+
34+
a {
35+
color: yellow;
36+
}
37+
",
38+
"",
39+
],
40+
]
41+
`;
42+
43+
exports[`camelCase option dashes: warnings 1`] = `Array []`;
44+
45+
exports[`camelCase option dashesOnly: errors 1`] = `Array []`;
46+
47+
exports[`camelCase option dashesOnly: locals 1`] = `
48+
Object {
49+
"btnInfo_isDisabled": "_1XTfjK5gKYeSzbdZhEXRpF",
50+
"btnInfo_isDisabled_1": "jDvNwV-WRSMB9n2z9QrzR",
51+
"foo": "bar",
52+
"myBtnInfo_isDisabled": "value",
53+
"simple": "_1penVf9PMtov2qLxmtsMjq",
54+
}
55+
`;
56+
57+
exports[`camelCase option dashesOnly: module (evaluated) 1`] = `
58+
Array [
59+
Array [
60+
1,
61+
"._1XTfjK5gKYeSzbdZhEXRpF {
62+
color: blue;
63+
}
64+
65+
.jDvNwV-WRSMB9n2z9QrzR {
66+
color: blue;
67+
}
68+
69+
._1penVf9PMtov2qLxmtsMjq {
70+
color: red;
71+
}
72+
73+
a {
74+
color: yellow;
75+
}
76+
",
77+
"",
78+
],
79+
]
80+
`;
81+
82+
exports[`camelCase option dashesOnly: warnings 1`] = `Array []`;
83+
84+
exports[`camelCase option not specified: errors 1`] = `Array []`;
85+
86+
exports[`camelCase option not specified: locals 1`] = `
87+
Object {
88+
"btn--info_is-disabled_1": "jDvNwV-WRSMB9n2z9QrzR",
89+
"btn-info_is-disabled": "_1XTfjK5gKYeSzbdZhEXRpF",
90+
"foo": "bar",
91+
"my-btn-info_is-disabled": "value",
92+
"simple": "_1penVf9PMtov2qLxmtsMjq",
93+
}
94+
`;
95+
96+
exports[`camelCase option not specified: module (evaluated) 1`] = `
97+
Array [
98+
Array [
99+
1,
100+
"._1XTfjK5gKYeSzbdZhEXRpF {
101+
color: blue;
102+
}
103+
104+
.jDvNwV-WRSMB9n2z9QrzR {
105+
color: blue;
106+
}
107+
108+
._1penVf9PMtov2qLxmtsMjq {
109+
color: red;
110+
}
111+
112+
a {
113+
color: yellow;
114+
}
115+
",
116+
"",
117+
],
118+
]
119+
`;
120+
121+
exports[`camelCase option not specified: warnings 1`] = `Array []`;
122+
123+
exports[`camelCase option only: errors 1`] = `Array []`;
124+
125+
exports[`camelCase option only: locals 1`] = `
126+
Object {
127+
"btnInfoIsDisabled": "_1XTfjK5gKYeSzbdZhEXRpF",
128+
"btnInfoIsDisabled1": "jDvNwV-WRSMB9n2z9QrzR",
129+
"foo": "bar",
130+
"myBtnInfoIsDisabled": "value",
131+
"simple": "_1penVf9PMtov2qLxmtsMjq",
132+
}
133+
`;
134+
135+
exports[`camelCase option only: module (evaluated) 1`] = `
136+
Array [
137+
Array [
138+
1,
139+
"._1XTfjK5gKYeSzbdZhEXRpF {
140+
color: blue;
141+
}
142+
143+
.jDvNwV-WRSMB9n2z9QrzR {
144+
color: blue;
145+
}
146+
147+
._1penVf9PMtov2qLxmtsMjq {
148+
color: red;
149+
}
150+
151+
a {
152+
color: yellow;
153+
}
154+
",
155+
"",
156+
],
157+
]
158+
`;
159+
160+
exports[`camelCase option only: warnings 1`] = `Array []`;
161+
162+
exports[`camelCase option true: errors 1`] = `Array []`;
163+
164+
exports[`camelCase option true: locals 1`] = `
165+
Object {
166+
"btn--info_is-disabled_1": "jDvNwV-WRSMB9n2z9QrzR",
167+
"btn-info_is-disabled": "_1XTfjK5gKYeSzbdZhEXRpF",
168+
"btnInfoIsDisabled": "_1XTfjK5gKYeSzbdZhEXRpF",
169+
"btnInfoIsDisabled1": "jDvNwV-WRSMB9n2z9QrzR",
170+
"foo": "bar",
171+
"my-btn-info_is-disabled": "value",
172+
"myBtnInfoIsDisabled": "value",
173+
"simple": "_1penVf9PMtov2qLxmtsMjq",
174+
}
175+
`;
176+
177+
exports[`camelCase option true: module (evaluated) 1`] = `
178+
Array [
179+
Array [
180+
1,
181+
"._1XTfjK5gKYeSzbdZhEXRpF {
182+
color: blue;
183+
}
184+
185+
.jDvNwV-WRSMB9n2z9QrzR {
186+
color: blue;
187+
}
188+
189+
._1penVf9PMtov2qLxmtsMjq {
190+
color: red;
191+
}
192+
193+
a {
194+
color: yellow;
195+
}
196+
",
197+
"",
198+
],
199+
]
200+
`;
201+
202+
exports[`camelCase option true: warnings 1`] = `Array []`;

test/camelCase-option.test.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
const { webpack, evaluated } = require('./helpers');
2+
3+
describe('camelCase option', () => {
4+
it('true', async () => {
5+
const config = {
6+
loader: {
7+
options: {
8+
modules: true,
9+
camelCase: true,
10+
},
11+
},
12+
};
13+
const testId = './modules/camelCase.css';
14+
const stats = await webpack(testId, config);
15+
const { modules } = stats.toJson();
16+
const module = modules.find((m) => m.id === testId);
17+
const evaluatedModule = evaluated(module.source);
18+
19+
expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
20+
expect(evaluatedModule.locals).toMatchSnapshot('locals');
21+
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
22+
expect(stats.compilation.errors).toMatchSnapshot('errors');
23+
});
24+
25+
it('not specified', async () => {
26+
const config = { loader: { options: { modules: true } } };
27+
const testId = './modules/camelCase.css';
28+
const stats = await webpack(testId, config);
29+
const { modules } = stats.toJson();
30+
const module = modules.find((m) => m.id === testId);
31+
const evaluatedModule = evaluated(module.source);
32+
33+
expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
34+
expect(evaluatedModule.locals).toMatchSnapshot('locals');
35+
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
36+
expect(stats.compilation.errors).toMatchSnapshot('errors');
37+
});
38+
39+
it('dashes', async () => {
40+
const config = {
41+
loader: {
42+
options: {
43+
modules: true,
44+
camelCase: 'dashes',
45+
},
46+
},
47+
};
48+
const testId = './modules/camelCase.css';
49+
const stats = await webpack(testId, config);
50+
const { modules } = stats.toJson();
51+
const module = modules.find((m) => m.id === testId);
52+
const evaluatedModule = evaluated(module.source);
53+
54+
expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
55+
expect(evaluatedModule.locals).toMatchSnapshot('locals');
56+
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
57+
expect(stats.compilation.errors).toMatchSnapshot('errors');
58+
});
59+
60+
it('only', async () => {
61+
const config = {
62+
loader: {
63+
options: {
64+
modules: true,
65+
camelCase: 'only',
66+
},
67+
},
68+
};
69+
const testId = './modules/camelCase.css';
70+
const stats = await webpack(testId, config);
71+
const { modules } = stats.toJson();
72+
const module = modules.find((m) => m.id === testId);
73+
const evaluatedModule = evaluated(module.source);
74+
75+
expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
76+
expect(evaluatedModule.locals).toMatchSnapshot('locals');
77+
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
78+
expect(stats.compilation.errors).toMatchSnapshot('errors');
79+
});
80+
81+
it('dashesOnly', async () => {
82+
const config = {
83+
loader: {
84+
options: {
85+
modules: true,
86+
camelCase: 'dashesOnly',
87+
},
88+
},
89+
};
90+
const testId = './modules/camelCase.css';
91+
const stats = await webpack(testId, config);
92+
const { modules } = stats.toJson();
93+
const module = modules.find((m) => m.id === testId);
94+
const evaluatedModule = evaluated(module.source);
95+
96+
expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
97+
expect(evaluatedModule.locals).toMatchSnapshot('locals');
98+
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
99+
expect(stats.compilation.errors).toMatchSnapshot('errors');
100+
});
101+
});

test/camelCase.test.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)