Skip to content

Commit bf7d225

Browse files
committed
add test for URL resolving
1 parent adbe29c commit bf7d225

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,18 @@
6464
"css-loader": "^0.21.0",
6565
"eslint": "^1.6.0",
6666
"extract-text-webpack-plugin": "^0.8.2",
67+
"file-loader": "^0.8.5",
6768
"inject-loader": "^2.0.1",
6869
"jade": "^1.11.0",
6970
"jsdom": "^7.2.2",
7071
"mkdirp": "^0.5.1",
7172
"mocha": "^2.2.5",
7273
"node-libs-browser": "^0.5.3",
7374
"rimraf": "^2.4.0",
74-
"vue-style-loader": "^1.0.0",
7575
"stylus-loader": "^1.4.0",
7676
"vue-hot-reload-api": "^1.2.0",
7777
"vue-html-loader": "^1.0.0",
78+
"vue-style-loader": "^1.0.0",
7879
"webpack": "^1.12.2"
7980
}
8081
}

test/fixtures/logo.png

12.5 KB
Loading

test/fixtures/resolve.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.testModule = require('./resolve.vue')

test/fixtures/resolve.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<img src="./logo.png">
3+
<img src="~fixtures/logo.png">
4+
</template>
5+
6+
<style>
7+
html { background-image: url(./logo.png); }
8+
body { background-image: url(~fixtures/logo.png); }
9+
</style>

test/test.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ describe('vue-loader', function () {
216216
})
217217
})
218218

219-
it('dependency injection', function () {
219+
it('dependency injection', function (done) {
220220
test({
221221
entry: './test/fixtures/inject.js'
222222
}, function (window) {
@@ -231,4 +231,27 @@ describe('vue-loader', function () {
231231
})
232232
})
233233

234+
it('translates relative URLs and respects resolve alias', function (done) {
235+
test({
236+
entry: './test/fixtures/resolve.js',
237+
resolve: {
238+
alias: {
239+
fixtures: path.resolve(__dirname, 'fixtures')
240+
}
241+
},
242+
module: {
243+
loaders: [
244+
{ test: /\.vue$/, loader: loaderPath },
245+
{ test: /\.png$/, loader: 'file-loader?name=[name].[hash:6].[ext]' }
246+
]
247+
}
248+
}, function (window) {
249+
var module = window.testModule
250+
expect(module.template).to.contain('<img src="logo.c9e00e.png">\n<img src="logo.c9e00e.png">')
251+
var style = window.document.querySelector('style').textContent
252+
expect(style).to.contain('html { background-image: url(logo.c9e00e.png); }')
253+
expect(style).to.contain('body { background-image: url(logo.c9e00e.png); }')
254+
done()
255+
})
256+
})
234257
})

0 commit comments

Comments
 (0)