test: fix hmr test
This commit is contained in:
parent
6abac87b3d
commit
51510adacb
@ -33,9 +33,9 @@ describe('hot module replacement', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('createRecord', () => {
|
test('createRecord', () => {
|
||||||
expect(createRecord('test1', {})).toBe(true)
|
expect(createRecord('test1')).toBe(true)
|
||||||
// if id has already been created, should return false
|
// if id has already been created, should return false
|
||||||
expect(createRecord('test1', {})).toBe(false)
|
expect(createRecord('test1')).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('rerender', async () => {
|
test('rerender', async () => {
|
||||||
@ -47,7 +47,7 @@ describe('hot module replacement', () => {
|
|||||||
__hmrId: childId,
|
__hmrId: childId,
|
||||||
render: compileToFunction(`<div><slot/></div>`)
|
render: compileToFunction(`<div><slot/></div>`)
|
||||||
}
|
}
|
||||||
createRecord(childId, Child)
|
createRecord(childId)
|
||||||
|
|
||||||
const Parent: ComponentOptions = {
|
const Parent: ComponentOptions = {
|
||||||
__hmrId: parentId,
|
__hmrId: parentId,
|
||||||
@ -59,7 +59,7 @@ describe('hot module replacement', () => {
|
|||||||
`<div @click="count++">{{ count }}<Child>{{ count }}</Child></div>`
|
`<div @click="count++">{{ count }}<Child>{{ count }}</Child></div>`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
createRecord(parentId, Parent)
|
createRecord(parentId)
|
||||||
|
|
||||||
render(h(Parent), root)
|
render(h(Parent), root)
|
||||||
expect(serializeInner(root)).toBe(`<div>0<div>0</div></div>`)
|
expect(serializeInner(root)).toBe(`<div>0<div>0</div></div>`)
|
||||||
@ -125,7 +125,7 @@ describe('hot module replacement', () => {
|
|||||||
unmounted: unmountSpy,
|
unmounted: unmountSpy,
|
||||||
render: compileToFunction(`<div @click="count++">{{ count }}</div>`)
|
render: compileToFunction(`<div @click="count++">{{ count }}</div>`)
|
||||||
}
|
}
|
||||||
createRecord(childId, Child)
|
createRecord(childId)
|
||||||
|
|
||||||
const Parent: ComponentOptions = {
|
const Parent: ComponentOptions = {
|
||||||
render: () => h(Child)
|
render: () => h(Child)
|
||||||
@ -166,7 +166,7 @@ describe('hot module replacement', () => {
|
|||||||
},
|
},
|
||||||
render: compileToFunction(template)
|
render: compileToFunction(template)
|
||||||
}
|
}
|
||||||
createRecord(id, Comp)
|
createRecord(id)
|
||||||
|
|
||||||
render(h(Comp), root)
|
render(h(Comp), root)
|
||||||
expect(serializeInner(root)).toBe(
|
expect(serializeInner(root)).toBe(
|
||||||
@ -203,14 +203,14 @@ describe('hot module replacement', () => {
|
|||||||
},
|
},
|
||||||
render: compileToFunction(`<div>{{ msg }}</div>`)
|
render: compileToFunction(`<div>{{ msg }}</div>`)
|
||||||
}
|
}
|
||||||
createRecord(childId, Child)
|
createRecord(childId)
|
||||||
|
|
||||||
const Parent: ComponentOptions = {
|
const Parent: ComponentOptions = {
|
||||||
__hmrId: parentId,
|
__hmrId: parentId,
|
||||||
components: { Child },
|
components: { Child },
|
||||||
render: compileToFunction(`<Child msg="foo" />`)
|
render: compileToFunction(`<Child msg="foo" />`)
|
||||||
}
|
}
|
||||||
createRecord(parentId, Parent)
|
createRecord(parentId)
|
||||||
|
|
||||||
render(h(Parent), root)
|
render(h(Parent), root)
|
||||||
expect(serializeInner(root)).toBe(`<div>foo</div>`)
|
expect(serializeInner(root)).toBe(`<div>foo</div>`)
|
||||||
@ -229,14 +229,14 @@ describe('hot module replacement', () => {
|
|||||||
__hmrId: childId,
|
__hmrId: childId,
|
||||||
render: compileToFunction(`<div>child</div>`)
|
render: compileToFunction(`<div>child</div>`)
|
||||||
}
|
}
|
||||||
createRecord(childId, Child)
|
createRecord(childId)
|
||||||
|
|
||||||
const Parent: ComponentOptions = {
|
const Parent: ComponentOptions = {
|
||||||
__hmrId: parentId,
|
__hmrId: parentId,
|
||||||
components: { Child },
|
components: { Child },
|
||||||
render: compileToFunction(`<Child class="test" />`)
|
render: compileToFunction(`<Child class="test" />`)
|
||||||
}
|
}
|
||||||
createRecord(parentId, Parent)
|
createRecord(parentId)
|
||||||
|
|
||||||
render(h(Parent), root)
|
render(h(Parent), root)
|
||||||
expect(serializeInner(root)).toBe(`<div class="test">child</div>`)
|
expect(serializeInner(root)).toBe(`<div class="test">child</div>`)
|
||||||
@ -256,7 +256,7 @@ describe('hot module replacement', () => {
|
|||||||
__hmrId: childId,
|
__hmrId: childId,
|
||||||
render: compileToFunction(`<div>child</div>`)
|
render: compileToFunction(`<div>child</div>`)
|
||||||
}
|
}
|
||||||
createRecord(childId, Child)
|
createRecord(childId)
|
||||||
|
|
||||||
const components: ComponentOptions[] = []
|
const components: ComponentOptions[] = []
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ describe('hot module replacement', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createRecord(parentId, parentComp)
|
createRecord(parentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const last = components[components.length - 1]
|
const last = components[components.length - 1]
|
||||||
|
Loading…
Reference in New Issue
Block a user