@@ -18,6 +18,7 @@ const rules = {
18
18
19
19
describe ( 'options' , ( ) => {
20
20
let fixture
21
+ let fixtures
21
22
let data
22
23
23
24
describe ( 'moduleName' , ( ) => {
@@ -116,6 +117,94 @@ describe('options', () => {
116
117
} )
117
118
} )
118
119
120
+ describe ( 'moduleName array' , ( ) => {
121
+ beforeEach ( done => {
122
+ stylelint
123
+ . lint ( {
124
+ files : fixtures ,
125
+ config : {
126
+ // Set moduleName option to "emotion"
127
+ processors : [ [ processor , { moduleName : [ 'emotion' , 'some-module' ] } ] ] ,
128
+ rules
129
+ }
130
+ } )
131
+ . then ( result => {
132
+ data = result
133
+ done ( )
134
+ } )
135
+ . catch ( err => {
136
+ // eslint-disable-next-line no-console
137
+ console . log ( err )
138
+ data = err
139
+ done ( )
140
+ } )
141
+ } )
142
+
143
+ describe ( 'moduleName' , ( ) => {
144
+ beforeAll ( ( ) => {
145
+ fixtures = [
146
+ slash ( path . join ( __dirname , './fixtures/options/module-name.js' ) ) ,
147
+ slash ( path . join ( __dirname , './fixtures/options/module-name-two.js' ) )
148
+ ]
149
+ } )
150
+
151
+ it ( 'should have one result' , ( ) => {
152
+ expect ( data . results . length ) . toEqual ( 2 )
153
+ } )
154
+
155
+ it ( 'should use the right file' , ( ) => {
156
+ expect ( [ slash ( data . results [ 0 ] . source ) , slash ( data . results [ 1 ] . source ) ] ) . toEqual ( fixtures )
157
+ } )
158
+
159
+ it ( 'should have errored' , ( ) => {
160
+ expect ( [ data . results [ 0 ] . errored , data . results [ 1 ] . errored ] ) . toEqual ( [ true , true ] )
161
+ } )
162
+
163
+ it ( 'should have one warning (i.e. wrong lines of code)' , ( ) => {
164
+ expect ( [ data . results [ 0 ] . warnings . length , data . results [ 1 ] . warnings . length ] ) . toEqual ( [ 1 , 1 ] )
165
+ } )
166
+
167
+ it ( 'should have a block-no-empty as the first warning' , ( ) => {
168
+ expect ( [ data . results [ 0 ] . warnings [ 0 ] . rule , data . results [ 1 ] . warnings [ 0 ] . rule ] ) . toEqual ( [
169
+ 'block-no-empty' ,
170
+ 'block-no-empty'
171
+ ] )
172
+ } )
173
+ } )
174
+
175
+ describe ( 'relative moduleName' , ( ) => {
176
+ beforeAll ( ( ) => {
177
+ fixtures = [
178
+ slash ( path . join ( __dirname , './fixtures/options/relative-module-name.js' ) ) ,
179
+ slash ( path . join ( __dirname , './fixtures/options/relative-module-name-two.js' ) )
180
+ ]
181
+ } )
182
+
183
+ it ( 'should have one result' , ( ) => {
184
+ expect ( data . results . length ) . toEqual ( 2 )
185
+ } )
186
+
187
+ it ( 'should use the right file' , ( ) => {
188
+ expect ( [ slash ( data . results [ 0 ] . source ) , slash ( data . results [ 1 ] . source ) ] ) . toEqual ( fixtures )
189
+ } )
190
+
191
+ it ( 'should have errored' , ( ) => {
192
+ expect ( [ data . results [ 0 ] . errored , data . results [ 1 ] . errored ] ) . toEqual ( [ true , true ] )
193
+ } )
194
+
195
+ it ( 'should have one warning (i.e. wrong lines of code)' , ( ) => {
196
+ expect ( [ data . results [ 0 ] . warnings . length , data . results [ 1 ] . warnings . length ] ) . toEqual ( [ 1 , 1 ] )
197
+ } )
198
+
199
+ it ( 'should have a block-no-empty as the first warning' , ( ) => {
200
+ expect ( [ data . results [ 0 ] . warnings [ 0 ] . rule , data . results [ 1 ] . warnings [ 0 ] . rule ] ) . toEqual ( [
201
+ 'block-no-empty' ,
202
+ 'block-no-empty'
203
+ ] )
204
+ } )
205
+ } )
206
+ } )
207
+
119
208
describe ( 'importName' , ( ) => {
120
209
// NOTE beforeEach() runs _after_ the beforeAll() hooks of the describe() blocks, so `fixture`
121
210
// will have the right path
0 commit comments