@@ -9,6 +9,7 @@ var moveModulesDir = require("./helpers/moveModulesDir.js");
99
1010var CR = / \r / g;
1111var bowerComponents = path . resolve ( __dirname , "./bower_components" ) ;
12+ var pathToLessLoader = path . resolve ( __dirname , "../index.js" ) ;
1213
1314describe ( "less-loader" , function ( ) {
1415 this . timeout ( 5000 ) ;
@@ -32,6 +33,7 @@ describe("less-loader", function() {
3233 test ( "should transform urls to files above the current directory" , "folder/url-path" ) ;
3334 test ( "should transform urls to files above the sibling directory" , "folder2/url-path" ) ;
3435 test ( "should generate source-map" , "source-map" , {
36+ query : "?sourceMap" ,
3537 devtool : "source-map"
3638 } ) ;
3739 it ( "should report error correctly" , function ( done ) {
@@ -67,11 +69,14 @@ function tryMkdirSync(dirname) {
6769 }
6870}
6971
70- function test ( name , id , hooks ) {
72+ function test ( name , id , testOptions ) {
73+ testOptions = testOptions || { } ;
74+ testOptions . query = testOptions . query || "" ;
75+
7176 it ( name , function ( done ) {
7277 var expectedCss = readCss ( id ) ;
7378 var lessFile = "raw!" +
74- path . resolve ( __dirname , "../index.js" ) + "!" +
79+ pathToLessLoader + testOptions . query + "!" +
7580 path . resolve ( __dirname , "./less/" + id + ".less" ) ;
7681 var actualCss ;
7782 var config = {
@@ -83,8 +88,7 @@ function test(name, id, hooks) {
8388 } ;
8489 var enhancedReq ;
8590
86- hooks = hooks || { } ;
87- hooks . before && hooks . before ( config ) ;
91+ testOptions . before && testOptions . before ( config ) ;
8892
8993 enhancedReq = enhancedReqFactory ( module , config ) ;
9094
@@ -99,7 +103,7 @@ function test(name, id, hooks) {
99103 // run asynchronously
100104 webpack ( {
101105 entry : lessFile ,
102- devtool : hooks . devtool ,
106+ devtool : testOptions . devtool ,
103107 resolve : config . resolve ,
104108 output : {
105109 path : __dirname + "/output" ,
@@ -125,9 +129,9 @@ function test(name, id, hooks) {
125129 fs . writeFileSync ( __dirname + "/output/" + name + ".async.css" , actualCss , "utf8" ) ;
126130 actualCss . should . eql ( expectedCss ) ;
127131
128- hooks . after && hooks . after ( ) ;
132+ testOptions . after && testOptions . after ( ) ;
129133
130- if ( hooks . devtool === "sourcemap" ) {
134+ if ( testOptions . devtool === "sourcemap" ) {
131135 actualMap = fs . readFileSync ( __dirname + "/output/bundle.js.map" , "utf8" ) ;
132136 fs . writeFileSync ( __dirname + "/output/" + name + ".sync.css.map" , actualMap , "utf8" ) ;
133137 actualMap = JSON . parse ( actualMap ) ;
0 commit comments