@@ -5,6 +5,7 @@ var jsdom = require('jsdom')
5
5
var expect = require ( 'chai' ) . expect
6
6
var assign = require ( 'object-assign' )
7
7
var rimraf = require ( 'rimraf' )
8
+ var hash = require ( 'hash-sum' )
8
9
var SourceMapConsumer = require ( 'source-map' ) . SourceMapConsumer
9
10
10
11
describe ( 'vue-loader' , function ( ) {
@@ -98,9 +99,10 @@ describe('vue-loader', function () {
98
99
'<p class="abc def v-5f0cf35a">hi</p>'
99
100
)
100
101
var style = window . document . querySelector ( 'style' ) . textContent
101
- expect ( style ) . to . match ( / d i v \. v - 5 f 0 c f 3 5 a \. t e s t { \s + c o l o r : b l u e ; \n } / )
102
- expect ( style ) . to . match ( / \. v - 5 f 0 c f 3 5 a { \s + c o l o r : r e d ; \n } / )
103
- expect ( style ) . to . match ( / \. v - 5 f 0 c f 3 5 a h 1 { \s + c o l o r : g r e e n ; \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}' )
104
106
done ( )
105
107
} )
106
108
} )
@@ -110,9 +112,10 @@ describe('vue-loader', function () {
110
112
entry : './test/fixtures/import.vue'
111
113
} , function ( window ) {
112
114
var styles = window . document . querySelectorAll ( 'style' )
113
- expect ( styles [ 0 ] . textContent ) . to . match ( / h 1 { c o l o r : r e d ; } / )
115
+ expect ( styles [ 0 ] . textContent ) . to . contain ( ' h1 { color: red; }' )
114
116
// import with local
115
- expect ( styles [ 1 ] . textContent ) . to . match ( / \. v - 5 7 5 1 b 9 b 6 h 1 { \s + c o l o r : g r e e n ; \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}' )
116
119
done ( )
117
120
} )
118
121
} )
0 commit comments