]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: add more tests
authordaiwei <daiwei521@126.com>
Tue, 19 Aug 2025 01:19:20 +0000 (09:19 +0800)
committerdaiwei <daiwei521@126.com>
Tue, 19 Aug 2025 01:19:20 +0000 (09:19 +0800)
packages/runtime-vapor/__tests__/hydration.spec.ts

index 40db6dd7c28afda8289e5eba54159b92c9eaed8a..d558c690e51653c4ff0d4a05bca8e2c32575b53e 100644 (file)
@@ -1791,23 +1791,45 @@ describe('Vapor Mode hydration', () => {
 
   describe('for', () => {
     test('basic v-for', async () => {
+      const { container, data } = await testHydration(
+        `<template>
+          <span v-for="item in data" :key="item">{{ item }}</span>
+        </template>`,
+        undefined,
+        ref(['a', 'b', 'c']),
+      )
+      expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
+        `"<span>a</span><span>b</span><span>c</span><!--for-->"`,
+      )
+
+      data.value.push('d')
+      await nextTick()
+      expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
+        `"<span>a</span><span>b</span><span>c</span><span>d</span><!--for-->"`,
+      )
+    })
+
+    test('v-for with insertion parent + sibling component', async () => {
       const { container, data } = await testHydration(
         `<template>
           <div>
             <span v-for="item in data" :key="item">{{ item }}</span>
           </div>
+          <components.Child/>
         </template>`,
-        undefined,
+        {
+          Child: `<template><div>{{data.length}}</div></template>`,
+        },
         ref(['a', 'b', 'c']),
       )
       expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
-        `"<div><span>a</span><span>b</span><span>c</span><!--for--></div>"`,
+        `"<div><span>a</span><span>b</span><span>c</span><!--for--></div><div>3</div>"`,
       )
 
       data.value.push('d')
       await nextTick()
       expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot(
-        `"<div><span>a</span><span>b</span><span>c</span><span>d</span><!--for--></div>"`,
+        `"<div><span>a</span><span>b</span><span>c</span><span>d</span><!--for--></div><div>4</div>"`,
       )
     })