@@ -173,75 +173,72 @@ describe('react-webpack:component', () => {
173173 }
174174
175175 // Run all tests for all available style types.
176- testComponentWithStyle ( styleTypes . css ) ;
177- testComponentWithStyle ( styleTypes . sass ) ;
178- testComponentWithStyle ( styleTypes . scss ) ;
179- testComponentWithStyle ( styleTypes . less ) ;
180- testComponentWithStyle ( styleTypes . stylus ) ;
181-
182- // Test stateless components (should be enough when testing with defaults)
183- testComponentWithStyle ( styleTypes . css , { stateless : true } ) ;
176+ // Stateless components will also be tested!
177+ for ( const style in styleTypes ) {
178+ testComponentWithStyle ( styleTypes [ style ] ) ;
179+ testComponentWithStyle ( styleTypes [ style ] , { stateless : true } ) ;
180+ }
184181 } ) ;
185182
186183 describe ( 'when using version 4 of the generator' , ( ) => {
187184
185+ /**
186+ * @var {yeoman.generator} generator
187+ * Global generator instance, set by createGeneratedComponent
188+ */
189+ let generator ;
190+
188191 // List of available style types. Please add a line that says
189192 // testComponentWithStyle(styleTypes.KEY); to the bottom of the file
190193 // to run all unit tests for this filetype.
191194 const styleTypes = {
192195 css : {
193196 type : 'css' ,
194- fileName : 'src/styles/Mycomponent .css' ,
195- expandedFileName : 'src/styles /my/littleSpecial/Test .css' ,
197+ fileName : 'src/components/mycomponent.cssmodule .css' ,
198+ expandedFileName : 'src/components /my/littleSpecial/test.cssmodule .css' ,
196199 assertions : {
197- componentImport : 'import styles from \'styles//Mycomponent .css\';' ,
200+ componentImport : 'import styles from \'./mycomponent.cssmodule .css\';' ,
198201 styleContent : '.mycomponent-component'
199202 }
200203 } ,
201204 sass : {
202205 type : 'sass' ,
203- fileName : 'src/styles /Mycomponent.sass' ,
204- expandedFileName : 'src/styles /my/littleSpecial/Test .sass' ,
206+ fileName : 'src/components /Mycomponent.cssmodule .sass' ,
207+ expandedFileName : 'src/components /my/littleSpecial/test.cssmodule .sass' ,
205208 assertions : {
206- componentImport : 'import styles from \'styles//Mycomponent .sass\';' ,
209+ componentImport : 'import styles from \'./mycomponent.cssmodule .sass\';' ,
207210 styleContent : '.mycomponent-component'
208211 }
209212 } ,
210213 scss : {
211214 type : 'scss' ,
212- fileName : 'src/styles/Mycomponent .scss' ,
213- expandedFileName : 'src/styles /my/littleSpecial/Test .scss' ,
215+ fileName : 'src/components/mycomponent.cssmodule .scss' ,
216+ expandedFileName : 'src/components /my/littleSpecial/test.cssmodule .scss' ,
214217 assertions : {
215- componentImport : 'import styles from \'styles//Mycomponent .scss\';' ,
218+ componentImport : 'import styles from \'./mycomponent.cssmodule .scss\';' ,
216219 styleContent : '.mycomponent-component'
217220 }
218221 } ,
219222 less : {
220223 type : 'less' ,
221- fileName : 'src/styles/Mycomponent .less' ,
222- expandedFileName : 'src/styles /my/littleSpecial/Test .less' ,
224+ fileName : 'src/components/mycomponent.cssmodule .less' ,
225+ expandedFileName : 'src/components /my/littleSpecial/test.cssmodule .less' ,
223226 assertions : {
224- componentImport : 'import styles from \'styles//Mycomponent .less\';' ,
227+ componentImport : 'import styles from \'./mycomponent.cssmodule .less\';' ,
225228 styleContent : '.mycomponent-component'
226229 }
227230 } ,
228231 stylus : {
229232 type : 'stylus' ,
230- fileName : 'src/styles/Mycomponent .styl' ,
231- expandedFileName : 'src/styles /my/littleSpecial/Test .styl' ,
233+ fileName : 'src/components/mycomponent.cssmodule .styl' ,
234+ expandedFileName : 'src/components /my/littleSpecial/test.cssmodule .styl' ,
232235 assertions : {
233- componentImport : 'import styles from \'styles//Mycomponent .styl\';' ,
236+ componentImport : 'import styles from \'./mycomponent.cssmodule .styl\';' ,
234237 styleContent : '.mycomponent-component'
235238 }
236239 }
237240 } ;
238241
239- /**
240- * @var {yeoman.generator} generator
241- * Global generator instance, set by createGeneratedComponent
242- */
243- let generator ;
244-
245242 /**
246243 * Return a newly generated component with given name and style
247244 * @param {String } name Name of the component
@@ -281,9 +278,9 @@ describe('react-webpack:component', () => {
281278 createGeneratedComponent ( 'mycomponent' , style . type , options , ( ) => {
282279
283280 assert . file ( [
284- 'src/components/MycomponentComponent .js' ,
281+ 'src/components/Mycomponent .js' ,
285282 style . fileName ,
286- 'test/components/MycomponentComponentTest .js'
283+ 'test/components/MycomponentTest .js'
287284 ] ) ;
288285 done ( ) ;
289286 } ) ;
@@ -294,21 +291,21 @@ describe('react-webpack:component', () => {
294291
295292 it ( 'should always import REACT' , ( done ) => {
296293 createGeneratedComponent ( 'mycomponent' , style . type , options , ( ) => {
297- assert . fileContent ( 'src/components/MycomponentComponent .js' , 'import React from \'react\';' ) ;
294+ assert . fileContent ( 'src/components/Mycomponent .js' , 'import React from \'react\';' ) ;
298295 done ( ) ;
299296 } ) ;
300297 } ) ;
301298
302299 it ( `should require the created ${ style . type } file` , ( done ) => {
303300 createGeneratedComponent ( 'mycomponent' , style . type , options , ( ) => {
304- assert . fileContent ( 'src/components/MycomponentComponent .js' , style . assertions . componentImport ) ;
301+ assert . fileContent ( 'src/components/Mycomponent .js' , style . assertions . componentImport ) ;
305302 done ( ) ;
306303 } ) ;
307304 } ) ;
308305
309306 it ( 'should have its displayName set per default' , ( done ) => {
310307 createGeneratedComponent ( 'mycomponent' , style . type , options , ( ) => {
311- assert . fileContent ( 'src/components/MycomponentComponent .js' , 'displayName = \'MycomponentComponent \';' ) ;
308+ assert . fileContent ( 'src/components/Mycomponent .js' , 'Mycomponent. displayName = \'Mycomponent \';' ) ;
312309 done ( ) ;
313310 } ) ;
314311 } ) ;
@@ -318,11 +315,11 @@ describe('react-webpack:component', () => {
318315
319316 let exportAssertion ;
320317 if ( generator . options . stateless ) {
321- exportAssertion = 'export default cssmodules(MycomponentComponent , styles);' ;
318+ exportAssertion = 'export default cssmodules(Mycomponent , styles);' ;
322319 } else {
323- exportAssertion = 'export default MycomponentComponent ' ;
320+ exportAssertion = 'export default Mycomponent ' ;
324321 }
325- assert . fileContent ( 'src/components/MycomponentComponent .js' , exportAssertion ) ;
322+ assert . fileContent ( 'src/components/Mycomponent .js' , exportAssertion ) ;
326323 done ( ) ;
327324 } ) ;
328325 } ) ;
@@ -331,9 +328,9 @@ describe('react-webpack:component', () => {
331328 createGeneratedComponent ( 'my/little !special/test' , style . type , options , ( ) => {
332329
333330 assert . file ( [
334- 'src/components/my/littleSpecial/TestComponent .js' ,
331+ 'src/components/my/littleSpecial/Test .js' ,
335332 style . expandedFileName ,
336- 'test/components/my/littleSpecial/TestComponentTest .js'
333+ 'test/components/my/littleSpecial/TestTest .js'
337334 ] ) ;
338335 done ( ) ;
339336 } ) ;
@@ -354,7 +351,7 @@ describe('react-webpack:component', () => {
354351
355352 it ( 'should import the react component' , ( done ) => {
356353 createGeneratedComponent ( 'mycomponent' , style . type , options , ( ) => {
357- assert . fileContent ( 'test/components/MycomponentComponentTest .js' , 'import MycomponentComponent from \'components//MycomponentComponent .js\';' ) ;
354+ assert . fileContent ( 'test/components/MycomponentTest .js' , 'import Mycomponent from \'components//Mycomponent .js\';' ) ;
358355 done ( ) ;
359356 } ) ;
360357 } ) ;
@@ -363,14 +360,11 @@ describe('react-webpack:component', () => {
363360 }
364361
365362 // Run all tests for all available style types.
366- testComponentWithStyle ( styleTypes . css ) ;
367- testComponentWithStyle ( styleTypes . sass ) ;
368- testComponentWithStyle ( styleTypes . scss ) ;
369- testComponentWithStyle ( styleTypes . less ) ;
370- testComponentWithStyle ( styleTypes . stylus ) ;
371-
372- // Test stateless components (should be enough when testing with defaults)
373- testComponentWithStyle ( styleTypes . css , { stateless : true } ) ;
363+ // Stateless components will also be tested!
364+ for ( const style in styleTypes ) {
365+ testComponentWithStyle ( styleTypes [ style ] ) ;
366+ testComponentWithStyle ( styleTypes [ style ] , { stateless : true } ) ;
367+ }
374368 } ) ;
375369
376370} ) ;
0 commit comments