@@ -12,6 +12,12 @@ describe("basic tests", function() {
12
12
var requiredCss = ".required { color: blue }" ,
13
13
requiredCssTwo = ".requiredTwo { color: cyan }" ,
14
14
localScopedCss = ":local(.className) { background: red; }" ,
15
+ localComposingCss = `
16
+ :local(.composingClass) {
17
+ composes: className from './localScoped.css';
18
+ color: blue;
19
+ }
20
+ ` ,
15
21
requiredStyle = `<style type="text/css">${ requiredCss } </style>` ,
16
22
existingStyle = "<style>.existing { color: yellow }</style>" ,
17
23
checkValue = '<div class="check">check</div>' ,
@@ -71,6 +77,7 @@ describe("basic tests", function() {
71
77
fs . writeFileSync ( rootDir + "style.css" , requiredCss ) ;
72
78
fs . writeFileSync ( rootDir + "styleTwo.css" , requiredCssTwo ) ;
73
79
fs . writeFileSync ( rootDir + "localScoped.css" , localScopedCss ) ;
80
+ fs . writeFileSync ( rootDir + "localComposing.css" , localComposingCss ) ;
74
81
} ) ; // before each
75
82
76
83
it ( "insert at bottom" , function ( done ) {
@@ -239,7 +246,7 @@ describe("basic tests", function() {
239
246
} ,
240
247
{
241
248
loader : "css-loader" ,
242
- options : {
249
+ options : {
243
250
localIdentName : '[name].[local]_[hash:base64:7]'
244
251
}
245
252
}
@@ -256,14 +263,72 @@ describe("basic tests", function() {
256
263
runCompilerTest ( expected , done , function ( ) { return this . css . className ; } ) ;
257
264
} ) ; // it local scope
258
265
266
+ it ( "local scope, composing" , function ( done ) {
267
+ cssRule . use = [
268
+ {
269
+ loader : "style-loader"
270
+ } ,
271
+ {
272
+ loader : "css-loader" ,
273
+ options : {
274
+ localIdentName : '[name].[local]_[hash:base64:7]'
275
+ }
276
+ }
277
+ ] ;
278
+
279
+ fs . writeFileSync (
280
+ rootDir + "main.js" ,
281
+ [
282
+ "css = require('./localComposing.css');"
283
+ ] . join ( "\n" )
284
+ ) ;
285
+
286
+ let expected =
287
+ 'localComposing-composingClass_3kXcqag localScoped-className_3dIU6Uf' ;
288
+ runCompilerTest ( expected , done , function ( ) {
289
+ return this . css . composingClass ;
290
+ } ) ;
291
+ } ) ; // it local scope, composing
292
+
293
+ it ( "local scope, composing, custom getLocalIdent" , function ( done ) {
294
+ cssRule . use = [
295
+ {
296
+ loader : "style-loader"
297
+ } ,
298
+ {
299
+ loader : "css-loader" ,
300
+ options : {
301
+ ident : 'css' ,
302
+ localIdentName : '[name].[local]_[hash:base64:7]' ,
303
+ getLocalIdent : ( context , localIdentName , localName ) => {
304
+ return 'X' + localName ;
305
+ }
306
+ }
307
+ }
308
+ ] ;
309
+
310
+ fs . writeFileSync (
311
+ rootDir + "main.js" ,
312
+ [
313
+ "css = require('./localComposing.css');"
314
+ ] . join ( "\n" )
315
+ ) ;
316
+
317
+ let expected =
318
+ 'XcomposingClass XclassName' ;
319
+ runCompilerTest ( expected , done , function ( ) {
320
+ return this . css . composingClass ;
321
+ } ) ;
322
+ } ) ; // it local scope, composing, custom getLocalIdent
323
+
259
324
it ( "local scope, useable" , function ( done ) {
260
325
cssRule . use = [
261
326
{
262
327
loader : "style-loader/useable"
263
328
} ,
264
329
{
265
330
loader : "css-loader" ,
266
- options : {
331
+ options : {
267
332
localIdentName : '[name].[local]_[hash:base64:7]'
268
333
}
269
334
}
0 commit comments