|
| 1 | +/*globals describe */ |
| 2 | + |
| 3 | +var test = require("./helpers").test; |
| 4 | + |
| 5 | +describe("alias", function() { |
| 6 | + var css = ".className { background: url(./path/to/file.png); }"; |
| 7 | + var exports = { |
| 8 | + without: [ |
| 9 | + [1, ".className { background: url({./path/to/file.png}); }", ""] |
| 10 | + ], |
| 11 | + onlyModule: [ |
| 12 | + [1, ".className { background: url({module/file.png}); }", ""] |
| 13 | + ], |
| 14 | + exactMatch: [ |
| 15 | + [1, ".className { background: url({module/file.png}); }", ""] |
| 16 | + ], |
| 17 | + notExactMatch: [ |
| 18 | + [1, ".className { background: url({./path/to/file.png}); }", ""] |
| 19 | + ], |
| 20 | + function: [ |
| 21 | + [1, ".className { background: url({return/value}); }", ""] |
| 22 | + ] |
| 23 | + }; |
| 24 | + |
| 25 | + function aliasOptions(alias) { |
| 26 | + return { options: { context: "", cssLoader: { alias: alias }}} |
| 27 | + } |
| 28 | + |
| 29 | + test("without", css, exports.without); |
| 30 | + test("onlyModule", css, exports.onlyModule, aliasOptions({ "./path/to": "module" })); |
| 31 | + test("exactMatch", css, exports.exactMatch, aliasOptions({ "./path/to/file.png$": "module/file.png" })); |
| 32 | + test("notExactMatch", css, exports.notExactMatch, aliasOptions({ "./path/to/file.jpg$": "module/file.jpg" })); |
| 33 | + test("function", css, exports.function, aliasOptions({ "./path/to": function(urlRequest) { return "return/value" } })); |
| 34 | +}); |
0 commit comments