Skip to content

Commit aababef

Browse files
committed
Add test for hmr option
1 parent 0acb10b commit aababef

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/template-loader.spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function mockRender (options, data = {}) {
3636
return options.render.call(Object.assign(mock, data))
3737
}
3838

39-
function loadCode(data, { style, query = '' } = {}) {
39+
function loadCode(data, { style, query = {}} = {}) {
4040
return loader.call({
4141
cacheable: () => {},
4242
options: {},
@@ -95,10 +95,22 @@ describe('vue-template-loader', () => {
9595
})
9696

9797
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 }})
9999
expect(code).toMatch(/options\._scopeId = 'data-v-[^']+'/)
100100
expect(code).toMatch(
101101
/require\('[^!?]*scoped-style-loader\.js\?id=[^!]+!\.\/style\.css'\)/
102102
)
103103
})
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+
})
104116
})

0 commit comments

Comments
 (0)