@@ -11,6 +11,7 @@ describe("basic tests", function() {
1111
1212 var requiredCss = ".required { color: blue }" ,
1313 requiredCssTwo = ".requiredTwo { color: cyan }" ,
14+ localScopedCss = ":local(.className) { background: red; }" ,
1415 requiredStyle = `<style type="text/css">${ requiredCss } </style>` ,
1516 existingStyle = "<style>.existing { color: yellow }</style>" ,
1617 rootDir = path . resolve ( __dirname + "/../" ) + "/" ,
@@ -65,6 +66,7 @@ describe("basic tests", function() {
6566 fs . writeFileSync ( rootDir + "main.js" , "var css = require('./style.css');" ) ;
6667 fs . writeFileSync ( rootDir + "style.css" , requiredCss ) ;
6768 fs . writeFileSync ( rootDir + "styleTwo.css" , requiredCssTwo ) ;
69+ fs . writeFileSync ( rootDir + "localScoped.css" , localScopedCss ) ;
6870 } ) ; // before each
6971
7072 it ( "insert at bottom" , function ( done ) {
@@ -143,8 +145,7 @@ describe("basic tests", function() {
143145 it ( "useable" , function ( done ) {
144146 cssRule . use = [
145147 {
146- loader : "style-loader/useable" ,
147- options : { }
148+ loader : "style-loader/useable"
148149 } ,
149150 "css-loader"
150151 ] ;
@@ -168,4 +169,53 @@ describe("basic tests", function() {
168169
169170 runCompilerTest ( expected , done ) ;
170171 } ) ; // it useable
172+
173+ it ( "local scope" , function ( done ) {
174+ cssRule . use = [
175+ {
176+ loader : "style-loader"
177+ } ,
178+ {
179+ loader : "css-loader" ,
180+ options : {
181+ localIdentName : '[name].[local]_[hash:base64:7]'
182+ }
183+ }
184+ ] ;
185+
186+ fs . writeFileSync (
187+ rootDir + "main.js" ,
188+ [
189+ "css = require('./localScoped.css');"
190+ ] . join ( "\n" )
191+ ) ;
192+
193+ let expected = 'localScoped-className_3dIU6Uf' ;
194+ runCompilerTest ( expected , done , function ( ) { return this . css . className ; } ) ;
195+ } ) ; // it local scope
196+
197+ it ( "local scope, useable" , function ( done ) {
198+ cssRule . use = [
199+ {
200+ loader : "style-loader/useable"
201+ } ,
202+ {
203+ loader : "css-loader" ,
204+ options : {
205+ localIdentName : '[name].[local]_[hash:base64:7]'
206+ }
207+ }
208+ ] ;
209+
210+ fs . writeFileSync (
211+ rootDir + "main.js" ,
212+ [
213+ "css = require('./localScoped.css');"
214+ ] . join ( "\n" )
215+ ) ;
216+
217+ let expected = 'localScoped-className_3dIU6Uf' ;
218+ runCompilerTest ( expected , done , function ( ) { return this . css . locals . className ; } ) ;
219+ } ) ; // it local scope
220+
171221} ) ; // describe
0 commit comments