@@ -36,7 +36,7 @@ function mockRender (options, data = {}) {
36
36
return options . render . call ( Object . assign ( mock , data ) )
37
37
}
38
38
39
- function loadCode ( data , { style, query = '' } = { } ) {
39
+ function loadCode ( data , { style, query = { } } = { } ) {
40
40
return loader . call ( {
41
41
cacheable : ( ) => { } ,
42
42
options : { } ,
@@ -95,10 +95,22 @@ describe('vue-template-loader', () => {
95
95
} )
96
96
97
97
it ( 'inject scoped id and scoped css' , ( ) => {
98
- const code = loadCode ( '<div>hi</div>' , { style : './style.css' , query : '? scoped' } )
98
+ const code = loadCode ( '<div>hi</div>' , { style : './style.css' , query : { scoped : true } } )
99
99
expect ( code ) . toMatch ( / o p t i o n s \. _ s c o p e I d = ' d a t a - v - [ ^ ' ] + ' / )
100
100
expect ( code ) . toMatch (
101
101
/ r e q u i r e \( ' [ ^ ! ? ] * s c o p e d - s t y l e - l o a d e r \. j s \? i d = [ ^ ! ] + ! \. \/ s t y l e \. c s s ' \) /
102
102
)
103
103
} )
104
+
105
+ it ( 'has the code for HMR' , ( ) => {
106
+ const code = loadCode ( '<div>hi</div>' )
107
+ expect ( code ) . toMatch ( 'vue-hot-reload-api' )
108
+ expect ( code ) . toMatch ( 'module.hot' )
109
+ } )
110
+
111
+ it ( 'disable HMR by option' , ( ) => {
112
+ const code = loadCode ( '<div>hi</div>' , { query : { hmr : false } } )
113
+ expect ( code ) . not . toMatch ( 'vue-hot-reload-api' )
114
+ expect ( code ) . not . toMatch ( 'module.hot' )
115
+ } )
104
116
} )
0 commit comments