@@ -380,35 +380,49 @@ describe('vue-loader', function () {
380
380
} )
381
381
382
382
it . only ( 'css-modules' , function ( done ) {
383
- test ( {
384
- entry : './test/fixtures/css-modules.vue'
385
- } , function ( window ) {
386
- var module = window . vueModule
387
-
388
- // get local class name
389
- var className = module . computed . style ( ) . red
390
- expect ( className ) . to . match ( / ^ _ / )
391
-
392
- // class name in style
393
- var style = [ ] . slice . call ( window . document . querySelectorAll ( 'style' ) ) . map ( function ( style ) {
394
- return style . textContent
395
- } ) . join ( '\n' )
396
- expect ( style ) . to . contain ( '.' + className + ' {\n color: red;\n}' )
397
-
398
- // animation name
399
- var match = style . match ( / @ k e y f r a m e s \s + ( \S + ) \s + { / )
400
- expect ( match ) . to . have . length ( 2 )
401
- var animationName = match [ 1 ]
402
- expect ( animationName ) . to . not . equal ( 'fade' )
403
- expect ( style ) . to . contain ( 'animation: ' + animationName + ' 1s;' )
404
-
405
- // default module + pre-processor + scoped
406
- var anotherClassName = module . computed . $style ( ) . red
407
- expect ( anotherClassName ) . to . match ( / ^ _ / ) . and . not . equal ( className )
408
- var id = 'data-v-' + genId ( require . resolve ( './fixtures/css-modules.vue' ) )
409
- expect ( style ) . to . contain ( '.' + anotherClassName + '[' + id + ']' )
410
-
411
- done ( )
383
+ function testWithIdent ( localIdentName , regexToMatch , cb ) {
384
+ test ( {
385
+ entry : './test/fixtures/css-modules.vue' ,
386
+ vue : {
387
+ cssModules : {
388
+ localIdentName : localIdentName
389
+ }
390
+ }
391
+ } , function ( window ) {
392
+ var module = window . vueModule
393
+
394
+ // get local class name
395
+ var className = module . computed . style ( ) . red
396
+ expect ( className ) . to . match ( regexToMatch )
397
+
398
+ // class name in style
399
+ var style = [ ] . slice . call ( window . document . querySelectorAll ( 'style' ) ) . map ( function ( style ) {
400
+ return style . textContent
401
+ } ) . join ( '\n' )
402
+ expect ( style ) . to . contain ( '.' + className + ' {\n color: red;\n}' )
403
+
404
+ // animation name
405
+ var match = style . match ( / @ k e y f r a m e s \s + ( \S + ) \s + { / )
406
+ expect ( match ) . to . have . length ( 2 )
407
+ var animationName = match [ 1 ]
408
+ expect ( animationName ) . to . not . equal ( 'fade' )
409
+ expect ( style ) . to . contain ( 'animation: ' + animationName + ' 1s;' )
410
+
411
+ // default module + pre-processor + scoped
412
+ var anotherClassName = module . computed . $style ( ) . red
413
+ expect ( anotherClassName ) . to . match ( regexToMatch ) . and . not . equal ( className )
414
+ var id = 'data-v-' + genId ( require . resolve ( './fixtures/css-modules.vue' ) )
415
+ expect ( style ) . to . contain ( '.' + anotherClassName + '[' + id + ']' )
416
+
417
+ cb ( )
418
+ } )
419
+ }
420
+ // default localIdentName
421
+ testWithIdent ( undefined , / ^ _ \w { 22 } / , function ( ) {
422
+ // specified localIdentName
423
+ var ident = '[path][name]---[local]---[hash:base64:5]'
424
+ var regex = / ^ t e s t - f i x t u r e s - c s s - m o d u l e s - - - r e d - - - \w { 5 } /
425
+ testWithIdent ( ident , regex , done )
412
426
} )
413
427
} )
414
428
} )
0 commit comments