test(ssr): more hydration tests
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
import { createSSRApp, h, ref, nextTick, VNode, Portal } from '@vue/runtime-dom'
|
||||
import {
|
||||
createSSRApp,
|
||||
h,
|
||||
ref,
|
||||
nextTick,
|
||||
VNode,
|
||||
Portal,
|
||||
createStaticVNode
|
||||
} from '@vue/runtime-dom'
|
||||
|
||||
function mountWithHydration(html: string, render: () => any) {
|
||||
const container = document.createElement('div')
|
||||
@@ -28,6 +36,21 @@ describe('SSR hydration', () => {
|
||||
expect(container.textContent).toBe('bar')
|
||||
})
|
||||
|
||||
test('comment', () => {
|
||||
const { vnode, container } = mountWithHydration('<!---->', () => null)
|
||||
expect(vnode.el).toBe(container.firstChild)
|
||||
expect(vnode.el.nodeType).toBe(8) // comment
|
||||
})
|
||||
|
||||
test('static', () => {
|
||||
const html = '<div><span>hello</span></div>'
|
||||
const { vnode, container } = mountWithHydration(html, () =>
|
||||
createStaticVNode(html)
|
||||
)
|
||||
expect(vnode.el).toBe(container.firstChild)
|
||||
expect(vnode.el.outerHTML).toBe(html)
|
||||
})
|
||||
|
||||
test('element with text children', async () => {
|
||||
const msg = ref('foo')
|
||||
const { vnode, container } = mountWithHydration(
|
||||
@@ -148,10 +171,6 @@ describe('SSR hydration', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('comment', () => {})
|
||||
|
||||
test('static', () => {})
|
||||
|
||||
// compile SSR + client render fn from the same template & hydrate
|
||||
test('full compiler integration', () => {})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user