@@ -5,65 +5,65 @@ const run = (input) => postcss([plugin]).process(input)
5
5
const runCSS = ( input ) => run ( input ) . then ( ( result ) => result . css )
6
6
const join = ( ...args ) => args . join ( '\n' )
7
7
8
- test ( 'should pass through an empty string' , ( ) =>
9
- expect ( runCSS ( '' ) ) . resolves . toEqual ( '' )
10
- )
8
+ test ( 'should pass through an empty string' , ( ) => {
9
+ return expect ( runCSS ( '' ) ) . resolves . toEqual ( '' )
10
+ } )
11
11
12
- test ( 'should export a constant' , ( ) =>
13
- expect ( runCSS ( '@value red blue;@value red blue;' ) ) . resolves . toEqual ( ':export {\n red: blue\n}' )
14
- )
12
+ test ( 'should export a constant' , ( ) => {
13
+ return expect ( runCSS ( '@value red blue;@value red blue;' ) ) . resolves . toEqual ( ':export {\n red: blue\n}' )
14
+ } )
15
15
16
- test ( 'gives an error when there is no semicolon between lines' , ( ) =>
17
- run ( '@value red blue\n@value green yellow' ) . then ( ( result ) => {
16
+ test ( 'gives an error when there is no semicolon between lines' , ( ) => {
17
+ return run ( '@value red blue\n@value green yellow' ) . then ( ( result ) => {
18
18
const warnings = result . warnings ( )
19
19
20
20
expect ( warnings . length ) . toEqual ( 1 )
21
21
expect ( warnings [ 0 ] . text ) . toEqual ( 'Invalid value definition: red blue\n@value green yellow' )
22
22
} )
23
- )
23
+ } )
24
24
25
- test ( 'should export a more complex constant' , ( ) =>
26
- expect ( runCSS ( '@value small (max-width: 599px);' ) ) . resolves . toEqual ( ':export {\n small: (max-width: 599px)\n}' )
27
- )
25
+ test ( 'should export a more complex constant' , ( ) => {
26
+ return expect ( runCSS ( '@value small (max-width: 599px);' ) ) . resolves . toEqual ( ':export {\n small: (max-width: 599px)\n}' )
27
+ } )
28
28
29
- test ( 'should replace constants within the file' , ( ) =>
30
- expect ( runCSS (
29
+ test ( 'should replace constants within the file' , ( ) => {
30
+ return expect ( runCSS (
31
31
'@value blue red; .foo { color: blue; }'
32
32
) ) . resolves . toEqual (
33
33
':export {\n blue: red;\n}\n.foo { color: red; }'
34
34
)
35
- )
35
+ } )
36
36
37
- test ( 'should import and re-export a simple constant' , ( ) =>
38
- expect ( runCSS (
37
+ test ( 'should import and re-export a simple constant' , ( ) => {
38
+ return expect ( runCSS (
39
39
'@value red from "./colors.css";'
40
40
) ) . resolves . toEqual (
41
41
':import("./colors.css") {\n i__const_red_0: red\n}\n:export {\n red: i__const_red_0\n}'
42
42
)
43
- )
43
+ } )
44
44
45
- test ( 'should import a simple constant and replace usages' , ( ) =>
46
- expect ( runCSS (
45
+ test ( 'should import a simple constant and replace usages' , ( ) => {
46
+ return expect ( runCSS (
47
47
'@value red from "./colors.css"; .foo { color: red; }'
48
48
) ) . resolves . toEqual ( join (
49
49
':import("./colors.css") {\n i__const_red_1: red;\n}' ,
50
50
':export {\n red: i__const_red_1;\n}' ,
51
51
'.foo { color: i__const_red_1; }'
52
52
) )
53
- )
53
+ } )
54
54
55
- test ( 'should import and alias a constant and replace usages' , ( ) =>
56
- expect ( runCSS (
55
+ test ( 'should import and alias a constant and replace usages' , ( ) => {
56
+ return expect ( runCSS (
57
57
'@value blue as red from "./colors.css"; .foo { color: red; }'
58
58
) ) . resolves . toEqual ( join (
59
59
':import("./colors.css") {\n i__const_red_2: blue;\n}' ,
60
60
':export {\n red: i__const_red_2;\n}' ,
61
61
'.foo { color: i__const_red_2; }'
62
62
) )
63
- )
63
+ } )
64
64
65
- test ( 'should import multiple from a single file' , ( ) =>
66
- expect ( runCSS ( join (
65
+ test ( 'should import multiple from a single file' , ( ) => {
66
+ return expect ( runCSS ( join (
67
67
'@value blue, red from "./colors.css";' ,
68
68
'.foo { color: red; }' ,
69
69
'.bar { color: blue }'
@@ -73,74 +73,74 @@ test('should import multiple from a single file', () =>
73
73
'.foo { color: i__const_red_4; }' ,
74
74
'.bar { color: i__const_blue_3 }'
75
75
) )
76
- )
76
+ } )
77
77
78
- test ( 'should import from a definition' , ( ) =>
79
- expect ( runCSS (
78
+ test ( 'should import from a definition' , ( ) => {
79
+ return expect ( runCSS (
80
80
'@value colors: "./colors.css"; @value red from colors;'
81
81
) ) . resolves . toEqual ( join (
82
82
':import("./colors.css") {\n i__const_red_5: red\n}' ,
83
83
':export {\n colors: "./colors.css";\n red: i__const_red_5\n}'
84
84
) )
85
- )
85
+ } )
86
86
87
- test ( 'should only allow values for paths if defined in the right order' , ( ) =>
88
- expect ( runCSS (
87
+ test ( 'should only allow values for paths if defined in the right order' , ( ) => {
88
+ return expect ( runCSS (
89
89
'@value red from colors; @value colors: "./colors.css";'
90
90
) ) . resolves . toEqual ( join (
91
91
':import(colors) {\n i__const_red_6: red\n}' ,
92
92
':export {\n red: i__const_red_6;\n colors: "./colors.css"\n}'
93
93
) )
94
- )
94
+ } )
95
95
96
- test ( 'should allow transitive values' , ( ) =>
97
- expect ( runCSS (
96
+ test ( 'should allow transitive values' , ( ) => {
97
+ return expect ( runCSS (
98
98
'@value aaa: red;\n@value bbb: aaa;\n.a { color: bbb; }'
99
99
) ) . resolves . toEqual (
100
100
':export {\n aaa: red;\n bbb: red;\n}\n.a { color: red; }'
101
101
)
102
- )
102
+ } )
103
103
104
- test ( 'should allow transitive values within calc' , ( ) =>
105
- expect ( runCSS (
104
+ test ( 'should allow transitive values within calc' , ( ) => {
105
+ return expect ( runCSS (
106
106
'@value base: 10px;\n@value large: calc(base * 2);\n.a { margin: large; }'
107
107
) ) . resolves . toEqual (
108
108
':export {\n base: 10px;\n large: calc(10px * 2);\n}\n.a { margin: calc(10px * 2); }'
109
109
)
110
- )
110
+ } )
111
111
112
- test ( 'should preserve import order' , ( ) =>
113
- expect ( runCSS (
112
+ test ( 'should preserve import order' , ( ) => {
113
+ return expect ( runCSS (
114
114
'@value a from "./a.css"; @value b from "./b.css";'
115
115
) ) . resolves . toEqual ( join (
116
116
':import("./a.css") {\n i__const_a_7: a\n}' ,
117
117
':import("./b.css") {\n i__const_b_8: b\n}' ,
118
118
':export {\n a: i__const_a_7;\n b: i__const_b_8\n}'
119
119
) )
120
- )
120
+ } )
121
121
122
- test ( 'should allow custom-property-style names' , ( ) =>
123
- expect ( runCSS (
122
+ test ( 'should allow custom-property-style names' , ( ) => {
123
+ return expect ( runCSS (
124
124
'@value --red from "./colors.css"; .foo { color: --red; }'
125
125
) ) . resolves . toEqual ( join (
126
126
':import("./colors.css") {\n i__const___red_9: --red;\n}' ,
127
127
':export {\n --red: i__const___red_9;\n}' ,
128
128
'.foo { color: i__const___red_9; }'
129
129
) )
130
- )
130
+ } )
131
131
132
- test ( 'should allow all colour types' , ( ) =>
133
- expect ( runCSS ( join (
132
+ test ( 'should allow all colour types' , ( ) => {
133
+ return expect ( runCSS ( join (
134
134
'@value named: red; @value 3char #0f0; @value 6char #00ff00; @value rgba rgba(34, 12, 64, 0.3); @value hsla hsla(220, 13.0%, 18.0%, 1);' ,
135
135
'.foo { color: named; background-color: 3char; border-top-color: 6char; border-bottom-color: rgba; outline-color: hsla; }'
136
136
) ) ) . resolves . toEqual ( join (
137
137
':export {\n named: red;\n 3char: #0f0;\n 6char: #00ff00;\n rgba: rgba(34, 12, 64, 0.3);\n hsla: hsla(220, 13.0%, 18.0%, 1);\n}' ,
138
138
'.foo { color: red; background-color: #0f0; border-top-color: #00ff00; border-bottom-color: rgba(34, 12, 64, 0.3); outline-color: hsla(220, 13.0%, 18.0%, 1); }'
139
139
) )
140
- )
140
+ } )
141
141
142
- test ( 'should import multiple from a single file on multiple lines' , ( ) =>
143
- expect ( runCSS ( join (
142
+ test ( 'should import multiple from a single file on multiple lines' , ( ) => {
143
+ return expect ( runCSS ( join (
144
144
'@value (\n blue,\n red\n) from "./colors.css";' ,
145
145
'.foo { color: red; }' ,
146
146
'.bar { color: blue }'
@@ -150,22 +150,22 @@ test('should import multiple from a single file on multiple lines', () =>
150
150
'.foo { color: i__const_red_11; }' ,
151
151
'.bar { color: i__const_blue_10 }'
152
152
) )
153
- )
153
+ } )
154
154
155
- test ( 'should allow definitions with commas in them' , ( ) =>
156
- expect ( runCSS ( join (
155
+ test ( 'should allow definitions with commas in them' , ( ) => {
156
+ return expect ( runCSS ( join (
157
157
'@value coolShadow: 0 11px 15px -7px rgba(0,0,0,.2),0 24px 38px 3px rgba(0,0,0,.14) ;' ,
158
158
'.foo { box-shadow: coolShadow; }'
159
159
) ) ) . resolves . toEqual ( join (
160
160
':export {\n coolShadow: 0 11px 15px -7px rgba(0,0,0,.2),0 24px 38px 3px rgba(0,0,0,.14);\n}' ,
161
161
'.foo { box-shadow: 0 11px 15px -7px rgba(0,0,0,.2),0 24px 38px 3px rgba(0,0,0,.14); }'
162
162
) )
163
- )
163
+ } )
164
164
165
- test ( 'should allow values with nested parantheses' , ( ) =>
166
- expect ( runCSS (
165
+ test ( 'should allow values with nested parantheses' , ( ) => {
166
+ return expect ( runCSS (
167
167
'@value aaa: color(red lightness(50%));'
168
168
) ) . resolves . toEqual (
169
169
':export {\n aaa: color(red lightness(50%))\n}'
170
170
)
171
- )
171
+ } )
0 commit comments