From 3999618e1300a9dffdb1f68c8ace5a2376b6ac04 Mon Sep 17 00:00:00 2001 From: daiwei Date: Fri, 1 Aug 2025 09:30:41 +0800 Subject: [PATCH] test: add tests for forwarded slots --- .../runtime-vapor/__tests__/hydration.spec.ts | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/packages/runtime-vapor/__tests__/hydration.spec.ts b/packages/runtime-vapor/__tests__/hydration.spec.ts index 20b357c508..86c110e203 100644 --- a/packages/runtime-vapor/__tests__/hydration.spec.ts +++ b/packages/runtime-vapor/__tests__/hydration.spec.ts @@ -2644,6 +2644,109 @@ describe('Vapor Mode hydration', () => { `bar`, ) }) + + test('forwarded slot', async () => { + const data = reactive({ + foo: 'foo', + bar: 'bar', + }) + const { container } = await testHydration( + ``, + { + Parent: ``, + Child: ``, + }, + data, + ) + expect(container.innerHTML).toBe( + `
` + + `
` + + `
` + + `` + + `foo` + + `` + + `` + + `
` + + `
` + + `
bar
` + + `
`, + ) + + data.foo = 'foo1' + data.bar = 'bar1' + await nextTick() + expect(container.innerHTML).toBe( + `
` + + `
` + + `
` + + `` + + `foo1` + + `` + + `` + + `
` + + `
` + + `
bar1
` + + `
`, + ) + }) + + test('forwarded slot with empty content', async () => { + const data = reactive({ + foo: 'foo', + }) + const { container } = await testHydration( + ``, + { + Foo: ``, + Bar: ``, + Baz: ``, + Qux: ``, + }, + data, + ) + + expect(container.innerHTML).toBe( + `
foo
`, + ) + + data.foo = 'bar' + await nextTick() + expect(container.innerHTML).toBe( + `
bar
`, + ) + }) }) describe.todo('transition', async () => { -- 2.47.2