Skip to content

Commit ee69e25

Browse files
committed
generate hash in tests
1 parent fdb9e43 commit ee69e25

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

test/test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var jsdom = require('jsdom')
55
var expect = require('chai').expect
66
var assign = require('object-assign')
77
var rimraf = require('rimraf')
8+
var hash = require('hash-sum')
89
var SourceMapConsumer = require('source-map').SourceMapConsumer
910

1011
describe('vue-loader', function () {
@@ -98,9 +99,10 @@ describe('vue-loader', function () {
9899
'<p class="abc def v-5f0cf35a">hi</p>'
99100
)
100101
var style = window.document.querySelector('style').textContent
101-
expect(style).to.match(/div\.v-5f0cf35a\.test {\s+color: blue;\n}/)
102-
expect(style).to.match(/\.v-5f0cf35a {\s+color: red;\n}/)
103-
expect(style).to.match(/\.v-5f0cf35a h1 {\s+color: green;\n}/)
102+
var cls = '.v-' + hash(require.resolve('./fixtures/local-css.vue'))
103+
expect(style).to.contain('div' + cls + '.test {\n color: blue;\n}')
104+
expect(style).to.contain(cls + ' {\n color: red;\n}')
105+
expect(style).to.contain(cls + ' h1 {\n color: green;\n}')
104106
done()
105107
})
106108
})
@@ -110,9 +112,10 @@ describe('vue-loader', function () {
110112
entry: './test/fixtures/import.vue'
111113
}, function (window) {
112114
var styles = window.document.querySelectorAll('style')
113-
expect(styles[0].textContent).to.match(/h1 { color: red; }/)
115+
expect(styles[0].textContent).to.contain('h1 { color: red; }')
114116
// import with local
115-
expect(styles[1].textContent).to.match(/\.v-5751b9b6 h1 {\s+color: green;\n}/)
117+
var cls = '.v-' + hash(require.resolve('./fixtures/import.local.css'))
118+
expect(styles[1].textContent).to.contain(cls + ' h1 {\n color: green;\n}')
116119
done()
117120
})
118121
})

0 commit comments

Comments
 (0)