@@ -19,6 +19,36 @@ module.exports = {
19
19
}
20
20
}
21
21
} ,
22
+ 'basic:import-fn' : {
23
+ message : 'supports { importFrom() } usage' ,
24
+ options : {
25
+ importFrom ( ) {
26
+ return {
27
+ customSelectors : {
28
+ ':--heading' : 'h1, h2, h3'
29
+ }
30
+ } ;
31
+ }
32
+ } ,
33
+ expect : 'basic.import.expect.css' ,
34
+ result : 'basic.import.result.css'
35
+ } ,
36
+ 'basic:import-fn-promise' : {
37
+ message : 'supports { async importFrom() } usage' ,
38
+ options : {
39
+ importFrom ( ) {
40
+ return new Promise ( resolve => {
41
+ resolve ( {
42
+ customSelectors : {
43
+ ':--heading' : 'h1, h2, h3'
44
+ }
45
+ } )
46
+ } ) ;
47
+ }
48
+ } ,
49
+ expect : 'basic.import.expect.css' ,
50
+ result : 'basic.import.result.css'
51
+ } ,
22
52
'basic:import-json' : {
23
53
message : 'supports { importFrom: "test/import-selectors.json" } usage' ,
24
54
options : {
@@ -42,6 +72,161 @@ module.exports = {
42
72
} ,
43
73
expect : 'basic.import.expect.css' ,
44
74
result : 'basic.import.result.css'
75
+ } ,
76
+ 'basic:import-css-from' : {
77
+ message : 'supports { importFrom: { from: "test/import-selectors.css" } } usage' ,
78
+ options : {
79
+ importFrom : { from : 'test/import-selectors.css' }
80
+ } ,
81
+ expect : 'basic.import.expect.css' ,
82
+ result : 'basic.import.result.css'
83
+ } ,
84
+ 'basic:import-css-from-type' : {
85
+ message : 'supports { importFrom: [ { from: "test/import-selectors.css", type: "css" } ] } usage' ,
86
+ options : {
87
+ importFrom : [ { from : 'test/import-selectors.css' , type : 'css' } ]
88
+ } ,
89
+ expect : 'basic.import.expect.css' ,
90
+ result : 'basic.import.result.css'
91
+ } ,
92
+ 'basic:export' : {
93
+ message : 'supports { exportTo: { customSelectors: { ... } } } usage' ,
94
+ options : {
95
+ exportTo : ( global . __exportSelectorObject = global . __exportSelectorObject || {
96
+ customSelectors : null
97
+ } )
98
+ } ,
99
+ expect : 'basic.expect.css' ,
100
+ result : 'basic.result.css' ,
101
+ after ( ) {
102
+ if ( __exportSelectorObject . customSelectors [ ':--foo' ] !== '.foo' ) {
103
+ throw new Error ( 'The exportTo function failed' ) ;
104
+ }
105
+ }
106
+ } ,
107
+ 'basic:export-fn' : {
108
+ message : 'supports { exportTo() } usage' ,
109
+ options : {
110
+ exportTo ( customProperties ) {
111
+ if ( customProperties [ ':--foo' ] !== '.foo' ) {
112
+ throw new Error ( 'The exportTo function failed' ) ;
113
+ }
114
+ }
115
+ } ,
116
+ expect : 'basic.expect.css' ,
117
+ result : 'basic.result.css'
118
+ } ,
119
+ 'basic:export-fn-promise' : {
120
+ message : 'supports { async exportTo() } usage' ,
121
+ options : {
122
+ exportTo ( customProperties ) {
123
+ return new Promise ( ( resolve , reject ) => {
124
+ if ( customProperties [ ':--foo' ] !== '.foo' ) {
125
+ reject ( 'The exportTo function failed' ) ;
126
+ } else {
127
+ resolve ( ) ;
128
+ }
129
+ } ) ;
130
+ }
131
+ } ,
132
+ expect : 'basic.expect.css' ,
133
+ result : 'basic.result.css'
134
+ } ,
135
+ 'basic:export-json' : {
136
+ message : 'supports { exportTo: "test/export-selectors.json" } usage' ,
137
+ options : {
138
+ exportTo : 'test/export-selectors.json'
139
+ } ,
140
+ expect : 'basic.expect.css' ,
141
+ result : 'basic.result.css' ,
142
+ before ( ) {
143
+ global . __exportSelectorsString = require ( 'fs' ) . readFileSync ( 'test/export-selectors.json' , 'utf8' ) ;
144
+ } ,
145
+ after ( ) {
146
+ if ( global . __exportSelectorsString !== require ( 'fs' ) . readFileSync ( 'test/export-selectors.json' , 'utf8' ) ) {
147
+ throw new Error ( 'The original file did not match the freshly exported copy' ) ;
148
+ }
149
+ }
150
+ } ,
151
+ 'basic:export-js' : {
152
+ message : 'supports { exportTo: "test/export-selectors.js" } usage' ,
153
+ options : {
154
+ exportTo : 'test/export-selectors.js'
155
+ } ,
156
+ expect : 'basic.expect.css' ,
157
+ result : 'basic.result.css' ,
158
+ before ( ) {
159
+ global . __exportSelectorsString = require ( 'fs' ) . readFileSync ( 'test/export-selectors.js' , 'utf8' ) ;
160
+ } ,
161
+ after ( ) {
162
+ if ( global . __exportSelectorsString !== require ( 'fs' ) . readFileSync ( 'test/export-selectors.js' , 'utf8' ) ) {
163
+ throw new Error ( 'The original file did not match the freshly exported copy' ) ;
164
+ }
165
+ }
166
+ } ,
167
+ 'basic:export-mjs' : {
168
+ message : 'supports { exportTo: "test/export-selectors.mjs" } usage' ,
169
+ options : {
170
+ exportTo : 'test/export-selectors.mjs'
171
+ } ,
172
+ expect : 'basic.expect.css' ,
173
+ result : 'basic.result.css' ,
174
+ before ( ) {
175
+ global . __exportSelectorsString = require ( 'fs' ) . readFileSync ( 'test/export-selectors.mjs' , 'utf8' ) ;
176
+ } ,
177
+ after ( ) {
178
+ if ( global . __exportSelectorsString !== require ( 'fs' ) . readFileSync ( 'test/export-selectors.mjs' , 'utf8' ) ) {
179
+ throw new Error ( 'The original file did not match the freshly exported copy' ) ;
180
+ }
181
+ }
182
+ } ,
183
+ 'basic:export-css' : {
184
+ message : 'supports { exportTo: "test/export-selectors.css" } usage' ,
185
+ options : {
186
+ exportTo : 'test/export-selectors.css'
187
+ } ,
188
+ expect : 'basic.expect.css' ,
189
+ result : 'basic.result.css' ,
190
+ before ( ) {
191
+ global . __exportSelectorsString = require ( 'fs' ) . readFileSync ( 'test/export-selectors.css' , 'utf8' ) ;
192
+ } ,
193
+ after ( ) {
194
+ if ( global . __exportSelectorsString !== require ( 'fs' ) . readFileSync ( 'test/export-selectors.css' , 'utf8' ) ) {
195
+ throw new Error ( 'The original file did not match the freshly exported copy' ) ;
196
+ }
197
+ }
198
+ } ,
199
+ 'basic:export-css-to' : {
200
+ message : 'supports { exportTo: { to: "test/export-selectors.css" } } usage' ,
201
+ options : {
202
+ exportTo : { to : 'test/export-selectors.css' }
203
+ } ,
204
+ expect : 'basic.expect.css' ,
205
+ result : 'basic.result.css' ,
206
+ before ( ) {
207
+ global . __exportSelectorsString = require ( 'fs' ) . readFileSync ( 'test/export-selectors.css' , 'utf8' ) ;
208
+ } ,
209
+ after ( ) {
210
+ if ( global . __exportSelectorsString !== require ( 'fs' ) . readFileSync ( 'test/export-selectors.css' , 'utf8' ) ) {
211
+ throw new Error ( 'The original file did not match the freshly exported copy' ) ;
212
+ }
213
+ }
214
+ } ,
215
+ 'basic:export-css-to-type' : {
216
+ message : 'supports { exportTo: { to: "test/export-selectors.css", type: "css" } } usage' ,
217
+ options : {
218
+ exportTo : { to : 'test/export-selectors.css' , type : 'css' }
219
+ } ,
220
+ expect : 'basic.expect.css' ,
221
+ result : 'basic.result.css' ,
222
+ before ( ) {
223
+ global . __exportSelectorsString = require ( 'fs' ) . readFileSync ( 'test/export-selectors.css' , 'utf8' ) ;
224
+ } ,
225
+ after ( ) {
226
+ if ( global . __exportSelectorsString !== require ( 'fs' ) . readFileSync ( 'test/export-selectors.css' , 'utf8' ) ) {
227
+ throw new Error ( 'The original file did not match the freshly exported copy' ) ;
228
+ }
229
+ }
45
230
}
46
231
}
47
232
} ;
0 commit comments