@@ -24,6 +24,29 @@ function run(resourcePath, query, content) {
2424 result: result
2525 }
2626}
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+ }
2750
2851function test(excepted, resourcePath, query, content) {
2952 run(resourcePath, query, content).file.should.be.eql(excepted);
@@ -86,4 +109,31 @@ describe("useRelativePath option", function() {
86109 'module.exports = __webpack_public_path__ + \"this/81dc9bdb52d04dc20036dbd8313ed055.txt\";'
87110 );
88111 });
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