@@ -11,12 +11,13 @@ import {
|
||||
nextTick
|
||||
} from '@vue/runtime-test'
|
||||
import * as runtimeTest from '@vue/runtime-test'
|
||||
import { registerRuntimeCompiler, createApp } from '@vue/runtime-test'
|
||||
import { baseCompile } from '@vue/compiler-core'
|
||||
|
||||
declare var __VUE_HMR_RUNTIME__: HMRRuntime
|
||||
const { createRecord, rerender, reload } = __VUE_HMR_RUNTIME__
|
||||
|
||||
runtimeTest.registerRuntimeCompiler(compileToFunction)
|
||||
registerRuntimeCompiler(compileToFunction)
|
||||
|
||||
function compileToFunction(template: string) {
|
||||
const { code } = baseCompile(template)
|
||||
@@ -395,4 +396,43 @@ describe('hot module replacement', () => {
|
||||
`<div style={}><div>1</div><div>2</div></div>`
|
||||
)
|
||||
})
|
||||
|
||||
// #4174
|
||||
test('with global mixins', async () => {
|
||||
const childId = 'hmr-global-mixin'
|
||||
const createSpy1 = jest.fn()
|
||||
const createSpy2 = jest.fn()
|
||||
|
||||
const Child: ComponentOptions = {
|
||||
__hmrId: childId,
|
||||
created: createSpy1,
|
||||
render() {
|
||||
return h('div')
|
||||
}
|
||||
}
|
||||
createRecord(childId, Child)
|
||||
|
||||
const Parent: ComponentOptions = {
|
||||
render: () => h(Child)
|
||||
}
|
||||
|
||||
const app = createApp(Parent)
|
||||
app.mixin({})
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
app.mount(root)
|
||||
expect(createSpy1).toHaveBeenCalledTimes(1)
|
||||
expect(createSpy2).toHaveBeenCalledTimes(0)
|
||||
|
||||
reload(childId, {
|
||||
__hmrId: childId,
|
||||
created: createSpy2,
|
||||
render() {
|
||||
return h('div')
|
||||
}
|
||||
})
|
||||
await nextTick()
|
||||
expect(createSpy1).toHaveBeenCalledTimes(1)
|
||||
expect(createSpy2).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user