]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test(runtime-vapor): add tests for dynamic components with vapor and vdom children
authordaiwei <daiwei521@126.com>
Mon, 17 Nov 2025 08:36:49 +0000 (16:36 +0800)
committeredison <daiwei521@126.com>
Mon, 17 Nov 2025 08:41:34 +0000 (16:41 +0800)
packages/runtime-vapor/__tests__/vdomInterop.spec.ts

index 50b190c9b79be0853ef34736f9d39bbd0f97e144..e3b7bfff64e80a6b3afc2ea7a6bac1df69f2b7b8 100644 (file)
@@ -14,6 +14,7 @@ import {
   provide,
   ref,
   renderSlot,
+  resolveDynamicComponent,
   shallowRef,
   toDisplayString,
   useModel,
@@ -323,7 +324,38 @@ describe('vdomInterop', () => {
     })
   })
 
-  describe.todo('dynamic component', () => {})
+  describe('dynamic component', () => {
+    it('dynamic component with vapor child', async () => {
+      const VaporChild = defineVaporComponent({
+        setup() {
+          return template('<div>vapor child</div>')() as any
+        },
+      })
+
+      const VdomChild = defineComponent({
+        setup() {
+          return () => h('div', 'vdom child')
+        },
+      })
+
+      const view = shallowRef<any>(VaporChild)
+      const { html } = define({
+        setup() {
+          return () => h(resolveDynamicComponent(view.value) as any)
+        },
+      }).render()
+
+      expect(html()).toBe('<div>vapor child</div>')
+
+      view.value = VdomChild
+      await nextTick()
+      expect(html()).toBe('<div>vdom child</div>')
+
+      view.value = VaporChild
+      await nextTick()
+      expect(html()).toBe('<div>vapor child</div>')
+    })
+  })
 
   describe('attribute fallthrough', () => {
     it('should fallthrough attrs to vdom child', () => {