1
1
const compiler = require ( './compiler.js' ) ;
2
2
3
3
const source = '<style>.red { color: red; }</style>\n<span class="$style.red">Red</span>' ;
4
+ const sourceShorthand = '<style>.red { color: red; }</style>\n<span class="$.red">Red</span>' ;
4
5
5
6
test ( 'Generate CSS Modules from HTML attributes, Replace CSS className' , async ( ) => {
6
7
const output = await compiler ( {
@@ -10,6 +11,14 @@ test('Generate CSS Modules from HTML attributes, Replace CSS className', async (
10
11
11
12
expect ( output ) . toBe ( '<style>:global(.red-123456) { color: red; }</style>\n<span class="red-123456">Red</span>' ) ;
12
13
} ) ;
14
+ test ( '[Shorthand] Generate CSS Modules from HTML attributes, Replace CSS className' , async ( ) => {
15
+ const output = await compiler ( {
16
+ source : sourceShorthand ,
17
+ localIdentName : '[local]-123456' ,
18
+ } ) ;
19
+
20
+ expect ( output ) . toBe ( '<style>:global(.red-123456) { color: red; }</style>\n<span class="red-123456">Red</span>' ) ;
21
+ } ) ;
13
22
14
23
test ( 'Avoid generated class to start with a non character' , async ( ) => {
15
24
const output = await compiler ( {
@@ -18,6 +27,13 @@ test('Avoid generated class to start with a non character', async () => {
18
27
} ) ;
19
28
expect ( output ) . toBe ( '<style>:global(._1red) { color: red; }</style>\n<span class="_1red">Red</span>' ) ;
20
29
} ) ;
30
+ test ( '[Shorthand] Avoid generated class to start with a non character' , async ( ) => {
31
+ const output = await compiler ( {
32
+ source : sourceShorthand ,
33
+ localIdentName : '1[local]' ,
34
+ } ) ;
35
+ expect ( output ) . toBe ( '<style>:global(._1red) { color: red; }</style>\n<span class="_1red">Red</span>' ) ;
36
+ } ) ;
21
37
22
38
test ( 'Avoid generated class to end with a hyphen' , async ( ) => {
23
39
const output = await compiler ( {
@@ -26,3 +42,10 @@ test('Avoid generated class to end with a hyphen', async () => {
26
42
} ) ;
27
43
expect ( output ) . toBe ( '<style>:global(.red) { color: red; }</style>\n<span class="red">Red</span>' ) ;
28
44
} ) ;
45
+ test ( '[Shorthand] Avoid generated class to end with a hyphen' , async ( ) => {
46
+ const output = await compiler ( {
47
+ source : sourceShorthand ,
48
+ localIdentName : '[local]-' ,
49
+ } ) ;
50
+ expect ( output ) . toBe ( '<style>:global(.red) { color: red; }</style>\n<span class="red">Red</span>' ) ;
51
+ } ) ;
0 commit comments