Skip to content

Commit caa0347

Browse files
author
Michael Vurchio
committed
Group tests
1 parent 2c0b5fd commit caa0347

File tree

1 file changed

+50
-42
lines changed

1 file changed

+50
-42
lines changed

test/replace.test.js

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,67 @@
11
const compiler = require('./compiler.js');
22

33
const style = '<style>.red { color: red; }</style>';
4-
const source = style + '\n<span class="$style.red">Red</span>';
5-
const sourceShorthand = style + '\n<span class="$.red">Red</span>';
4+
const source = `${style}\n<span class="$style.red">Red</span>`;
5+
const sourceShorthand = `${style}\n<span class="$.red">Red</span>`;
66

7+
describe('Generate CSS Modules from HTML attributes, Replace CSS className', () => {
8+
const expectedOutput = '<style>:global(.red-123456) { color: red; }</style>\n<span class="red-123456">Red</span>';
9+
test('Use default $style.', async () => {
10+
const output = await compiler({
11+
source,
12+
}, {
13+
localIdentName: '[local]-123456',
14+
});
715

8-
test('Generate CSS Modules from HTML attributes, Replace CSS className', async () => {
9-
const output = await compiler({
10-
source,
11-
}, {
12-
localIdentName: '[local]-123456',
16+
expect(output).toBe(expectedOutput);
1317
});
18+
test('Use shorthand $.', async () => {
19+
const output = await compiler({
20+
source: sourceShorthand,
21+
}, {
22+
localIdentName: '[local]-123456',
23+
});
1424

15-
expect(output).toBe('<style>:global(.red-123456) { color: red; }</style>\n<span class="red-123456">Red</span>');
16-
});
17-
test('[Shorthand] Generate CSS Modules from HTML attributes, Replace CSS className', async () => {
18-
const output = await compiler({
19-
source: sourceShorthand,
20-
}, {
21-
localIdentName: '[local]-123456',
25+
expect(output).toBe(expectedOutput);
2226
});
23-
24-
expect(output).toBe('<style>:global(.red-123456) { color: red; }</style>\n<span class="red-123456">Red</span>');
2527
});
2628

27-
test('Avoid generated class to start with a non character', async () => {
28-
const output = await compiler({
29-
source,
30-
}, {
31-
localIdentName: '1[local]',
29+
describe('Avoid generated class to start with a non character', () => {
30+
const expectedOutput = '<style>:global(._1red) { color: red; }</style>\n<span class="_1red">Red</span>';
31+
test('Use default $style.', async () => {
32+
const output = await compiler({
33+
source,
34+
}, {
35+
localIdentName: '1[local]',
36+
});
37+
expect(output).toBe(expectedOutput);
3238
});
33-
expect(output).toBe('<style>:global(._1red) { color: red; }</style>\n<span class="_1red">Red</span>');
34-
});
35-
test('[Shorthand] Avoid generated class to start with a non character', async () => {
36-
const output = await compiler({
37-
source: sourceShorthand,
38-
}, {
39-
localIdentName: '1[local]',
39+
test('Use shorthand $.', async () => {
40+
const output = await compiler({
41+
source: sourceShorthand,
42+
}, {
43+
localIdentName: '1[local]',
44+
});
45+
expect(output).toBe(expectedOutput);
4046
});
41-
expect(output).toBe('<style>:global(._1red) { color: red; }</style>\n<span class="_1red">Red</span>');
4247
});
4348

44-
test('Avoid generated class to end with a hyphen', async () => {
45-
const output = await compiler({
46-
source,
47-
}, {
48-
localIdentName: '[local]-',
49+
describe('Avoid generated class to end with a hyphen', () => {
50+
const expectedOutput = '<style>:global(.red) { color: red; }</style>\n<span class="red">Red</span>';
51+
test('Use default $style.', async () => {
52+
const output = await compiler({
53+
source,
54+
}, {
55+
localIdentName: '[local]-',
56+
});
57+
expect(output).toBe(expectedOutput);
4958
});
50-
expect(output).toBe('<style>:global(.red) { color: red; }</style>\n<span class="red">Red</span>');
51-
});
52-
test('[Shorthand] Avoid generated class to end with a hyphen', async () => {
53-
const output = await compiler({
54-
source: sourceShorthand,
55-
}, {
56-
localIdentName: '[local]-',
59+
test('Use shorthand $.', async () => {
60+
const output = await compiler({
61+
source: sourceShorthand,
62+
}, {
63+
localIdentName: '[local]-',
64+
});
65+
expect(output).toBe(expectedOutput);
5766
});
58-
expect(output).toBe('<style>:global(.red) { color: red; }</style>\n<span class="red">Red</span>');
5967
});

0 commit comments

Comments
 (0)