Skip to content

Commit ca34d4a

Browse files
committed
wip: add more tests
1 parent 7a842ab commit ca34d4a

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

packages/runtime-vapor/__tests__/hydration.spec.ts

+51-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,57 @@ describe('Vapor Mode hydration', () => {
9898
expect(container.innerHTML).toMatchInlineSnapshot(`"bar"`)
9999
})
100100

101-
test.todo('consecutive text nodes', () => {})
101+
test('consecutive text nodes', async () => {
102+
const { data, container } = await testHydration(`
103+
<template>{{ data }}{{ data }}</template>
104+
`)
105+
expect(container.innerHTML).toMatchInlineSnapshot(`"foofoo"`)
106+
107+
data.value = 'bar'
108+
await nextTick()
109+
expect(container.innerHTML).toMatchInlineSnapshot(`"barbar"`)
110+
})
111+
112+
test('consecutive text nodes with anchor insertion', async () => {
113+
const { data, container } = await testHydration(`
114+
<template><span/>{{ data }}{{ data }}<span/></template>
115+
`)
116+
expect(container.innerHTML).toMatchInlineSnapshot(
117+
`"<!--[--><span></span>foofoo<span></span><!--]-->"`,
118+
)
119+
120+
data.value = 'bar'
121+
await nextTick()
122+
expect(container.innerHTML).toMatchInlineSnapshot(
123+
`"<!--[--><span></span>barbar<span></span><!--]-->"`,
124+
)
125+
})
126+
127+
test('mixed text nodes', async () => {
128+
const { data, container } = await testHydration(`
129+
<template>{{ data }}A{{ data }}B{{ data }}</template>
130+
`)
131+
expect(container.innerHTML).toMatchInlineSnapshot(`"fooAfooBfoo"`)
132+
133+
data.value = 'bar'
134+
await nextTick()
135+
expect(container.innerHTML).toMatchInlineSnapshot(`"barAbarBbar"`)
136+
})
137+
138+
test('mixed text nodes with anchor insertion', async () => {
139+
const { data, container } = await testHydration(`
140+
<template><span/>{{ data }}A{{ data }}B{{ data }}<span/></template>
141+
`)
142+
expect(container.innerHTML).toMatchInlineSnapshot(
143+
`"<!--[--><span></span>fooAfooBfoo<span></span><!--]-->"`,
144+
)
145+
146+
data.value = 'bar'
147+
await nextTick()
148+
expect(container.innerHTML).toMatchInlineSnapshot(
149+
`"<!--[--><span></span>barAbarBbar<span></span><!--]-->"`,
150+
)
151+
})
102152
})
103153

104154
describe('element', () => {

0 commit comments

Comments
 (0)