@@ -109,25 +109,66 @@ describe('CSS Modules rewire', () => {
109
109
}
110
110
}
111
111
112
- it ( 'should enable CSS modules on the existing development CSS loader' , ( ) => {
113
- const result = subject ( mockDevelopmentConfig )
112
+ describe ( 'CSS loader' , ( ) => {
113
+ it ( 'should enable CSS modules (development)' , ( ) => {
114
+ const result = subject ( mockDevelopmentConfig )
114
115
115
- expect ( result . module . rules [ 1 ] . oneOf [ 2 ] . use [ 1 ] . options ) . toEqual ( {
116
- importLoaders : 1 ,
117
- modules : true ,
118
- localIdentName : '[local]___[hash:base64:5]'
116
+ expect ( result . module . rules [ 1 ] . oneOf [ 2 ] . use [ 1 ] . options ) . toEqual ( {
117
+ importLoaders : 1 ,
118
+ modules : true ,
119
+ localIdentName : '[local]___[hash:base64:5]'
120
+ } )
121
+ } )
122
+
123
+ it ( 'should enable CSS modules (production)' , ( ) => {
124
+ const result = subject ( mockProductionConfig )
125
+
126
+ expect ( result . module . rules [ 1 ] . oneOf [ 2 ] . loader [ 2 ] . options ) . toEqual ( {
127
+ importLoaders : 1 ,
128
+ minimize : true ,
129
+ sourceMap : true ,
130
+ modules : true ,
131
+ localIdentName : '[local]___[hash:base64:5]'
132
+ } )
119
133
} )
120
134
} )
121
135
122
- it ( 'should enable CSS modules on the existing production CSS loader' , ( ) => {
123
- const result = subject ( mockProductionConfig )
136
+ describe ( 'SASS loader' , ( ) => {
137
+ describe ( 'development' , ( ) => {
138
+
139
+ const result = subject ( mockDevelopmentConfig )
140
+ const cssLoader = result . module . rules [ 1 ] . oneOf [ 2 ]
141
+ const sassLoader = result . module . rules [ 1 ] . oneOf [ 3 ]
142
+
143
+ it ( 'should configure the test regex' , ( ) => {
144
+ expect ( result . module . rules [ 1 ] . oneOf [ 3 ] . test ) . toEqual ( / \. s [ a c ] s s $ / )
145
+ } )
146
+
147
+ it ( 'should build upon the CSS loader' , ( ) => {
148
+ expect ( sassLoader . use . slice ( 0 , 3 ) ) . toEqual ( cssLoader . use )
149
+ } )
150
+
151
+ it ( 'should append the sass-loader' , ( ) => {
152
+ expect ( sassLoader . use [ 3 ] ) . toContain ( '/sass-loader/' )
153
+ } )
154
+ } )
155
+
156
+ describe ( 'production' , ( ) => {
157
+ const result = subject ( mockProductionConfig )
158
+ const cssLoader = result . module . rules [ 1 ] . oneOf [ 2 ]
159
+ const sassLoader = result . module . rules [ 1 ] . oneOf [ 3 ]
160
+
161
+ it ( 'should configure the test regex' , ( ) => {
162
+ expect ( result . module . rules [ 1 ] . oneOf [ 3 ] . test ) . toEqual ( / \. s [ a c ] s s $ / )
163
+ } )
164
+
165
+ it ( 'should build upon the CSS loader' , ( ) => {
166
+ expect ( sassLoader . loader . slice ( 0 , 4 ) ) . toEqual ( cssLoader . loader )
167
+ } )
124
168
125
- expect ( result . module . rules [ 1 ] . oneOf [ 2 ] . loader [ 2 ] . options ) . toEqual ( {
126
- importLoaders : 1 ,
127
- minimize : true ,
128
- sourceMap : true ,
129
- modules : true ,
130
- localIdentName : '[local]___[hash:base64:5]'
169
+ it ( 'should append the sass-loader' , ( ) => {
170
+ expect ( sassLoader . loader [ 4 ] ) . toContain ( '/sass-loader/' )
171
+ } )
131
172
} )
132
173
} )
133
174
} )
0 commit comments