@@ -24,6 +24,29 @@ function run(resourcePath, query, content) {
24
24
result : result
25
25
}
26
26
}
27
+ function run_with_options ( resourcePath , options , content ) {
28
+ content = content || new Buffer ( "1234" ) ;
29
+ var file = null ;
30
+
31
+ var context = {
32
+ resourcePath : resourcePath ,
33
+ options : {
34
+ "fileLoader" : options ,
35
+ context : "/this/is/the/context"
36
+ } ,
37
+ emitFile : function ( url , content2 ) {
38
+ content2 . should . be . eql ( content ) ;
39
+ file = url ;
40
+ }
41
+ } ;
42
+
43
+ var result = fileLoader . call ( context , content )
44
+
45
+ return {
46
+ file : file ,
47
+ result : result
48
+ }
49
+ }
27
50
28
51
function test ( excepted , resourcePath , query , content ) {
29
52
run ( resourcePath , query , content ) . file . should . be . eql ( excepted ) ;
@@ -86,4 +109,31 @@ describe("useRelativePath option", function() {
86
109
'module.exports = __webpack_public_path__ + \"this/81dc9bdb52d04dc20036dbd8313ed055.txt\";'
87
110
) ;
88
111
} ) ;
89
- } ) ;
112
+ } ) ;
113
+ describe ( "outputPath function" , function ( ) {
114
+ it ( "should be supported" , function ( ) {
115
+ outputFunc = function ( value ) {
116
+ return ( "/path/set/by/func" ) ;
117
+
118
+ } ;
119
+ var options = { } ;
120
+ options . outputPath = outputFunc ;
121
+ run_with_options ( "/this/is/the/context/file.txt" , options ) . result . should . be . eql (
122
+ 'module.exports = __webpack_public_path__ + \"/path/set/by/func\";'
123
+ ) ;
124
+
125
+ } ) ;
126
+ it ( "should be ignored if you set useRelativePath" , function ( ) {
127
+ outputFunc = function ( value ) {
128
+ return ( "/path/set/by/func" ) ;
129
+
130
+ } ;
131
+ var options = { } ;
132
+ options . outputPath = outputFunc ;
133
+ options . useRelativePath = true ;
134
+ run_with_options ( "/this/is/the/context/file.txt" , options ) . result . should . be . eql (
135
+ 'module.exports = __webpack_public_path__ + \"./81dc9bdb52d04dc20036dbd8313ed055.txt\";'
136
+ ) ;
137
+
138
+ } ) ;
139
+ } ) ;
0 commit comments