]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: update directive handling to use withVaporDirectives and improve type safety
authordaiwei <daiwei521@126.com>
Thu, 27 Nov 2025 02:42:43 +0000 (10:42 +0800)
committerdaiwei <daiwei521@126.com>
Thu, 27 Nov 2025 02:42:43 +0000 (10:42 +0800)
packages/runtime-vapor/__tests__/apiCreateVaporApp.spec.ts

index 82da77b6208e1f0f26d8b3c2d20fb7f295c1d595..01aa7dc32bcb31f1bbb9ecff8697006e10a5f539 100644 (file)
@@ -1,10 +1,11 @@
 import {
+  type VaporDirective,
   createComponent,
   createTextNode,
   createVaporApp,
   defineVaporComponent,
-  // @ts-expect-error
-  withDirectives,
+  template,
+  withVaporDirectives,
 } from '../src'
 import {
   type GenericComponentInstance,
@@ -158,18 +159,17 @@ describe('api: createVaporApp', () => {
     expect(host.innerHTML).toBe(`foobar!barbaz!`)
   })
 
-  test.todo('directive', () => {
+  test('directive', () => {
     const spy1 = vi.fn()
     const spy2 = vi.fn()
 
     const { app, mount } = define({
       setup() {
-        const FooBar = resolveDirective('foo-bar')
-        const BarBaz = resolveDirective('bar-baz')
-        return withDirectives(document.createElement('div'), [
-          [FooBar],
-          [BarBaz],
-        ])
+        const FooBar = resolveDirective('foo-bar') as VaporDirective
+        const BarBaz = resolveDirective('bar-baz') as VaporDirective
+        const n0 = template('<div></div>')() as Element
+        withVaporDirectives(n0, [[FooBar], [BarBaz]])
+        return n0
       },
     }).create()