Skip to content

Commit c252e91

Browse files
committed
test: add more tests
1 parent 4db35b1 commit c252e91

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,23 +1791,45 @@ describe('Vapor Mode hydration', () => {
17911791

17921792
describe('for', () => {
17931793
test('basic v-for', async () => {
1794+
const { container, data } = await testHydration(
1795+
`<template>
1796+
<span v-for="item in data" :key="item">{{ item }}</span>
1797+
</template>`,
1798+
undefined,
1799+
ref(['a', 'b', 'c']),
1800+
)
1801+
expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
1802+
`"<span>a</span><span>b</span><span>c</span><!--for-->"`,
1803+
)
1804+
1805+
data.value.push('d')
1806+
await nextTick()
1807+
expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
1808+
`"<span>a</span><span>b</span><span>c</span><span>d</span><!--for-->"`,
1809+
)
1810+
})
1811+
1812+
test('v-for with insertion parent + sibling component', async () => {
17941813
const { container, data } = await testHydration(
17951814
`<template>
17961815
<div>
17971816
<span v-for="item in data" :key="item">{{ item }}</span>
17981817
</div>
1818+
<components.Child/>
17991819
</template>`,
1800-
undefined,
1820+
{
1821+
Child: `<template><div>{{data.length}}</div></template>`,
1822+
},
18011823
ref(['a', 'b', 'c']),
18021824
)
18031825
expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
1804-
`"<div><span>a</span><span>b</span><span>c</span><!--for--></div>"`,
1826+
`"<div><span>a</span><span>b</span><span>c</span><!--for--></div><div>3</div>"`,
18051827
)
18061828

18071829
data.value.push('d')
18081830
await nextTick()
18091831
expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
1810-
`"<div><span>a</span><span>b</span><span>c</span><span>d</span><!--for--></div>"`,
1832+
`"<div><span>a</span><span>b</span><span>c</span><span>d</span><!--for--></div><div>4</div>"`,
18111833
)
18121834
})
18131835

0 commit comments

Comments
 (0)