]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
test: fix template
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Sun, 26 Nov 2023 16:23:19 +0000 (00:23 +0800)
committer三咲智子 Kevin Deng <sxzz@sxzz.moe>
Sun, 26 Nov 2023 16:23:19 +0000 (00:23 +0800)
packages/runtime-vapor/__tests__/template.spec.ts

index da471b4322224a2b5b5f731bfdd9f003ecd2275d..32ea085f073e4670e67f5e63f8a9a560d9f8fceb 100644 (file)
@@ -2,16 +2,28 @@
  * @vitest-environment jsdom
  */
 
-import { template } from '../src'
+import { template, fragment } from '../src'
 
 describe('api: template', () => {
   test('create element', () => {
     const t = template('<div>')
-    const div = t()
-    expect(div).toBeInstanceOf(HTMLDivElement)
+    const root = t()
+    expect(root).toBeInstanceOf(DocumentFragment)
+    expect(root.childNodes[0]).toBeInstanceOf(HTMLDivElement)
 
     const div2 = t()
-    expect(div2).toBeInstanceOf(HTMLDivElement)
-    expect(div2).not.toBe(div)
+    expect(div2).toBeInstanceOf(DocumentFragment)
+    expect(div2).not.toBe(root)
+  })
+
+  test('create fragment', () => {
+    const frag = fragment()
+    const root = frag()
+    expect(root).toBeInstanceOf(DocumentFragment)
+    expect(root.childNodes.length).toBe(0)
+
+    const div2 = frag()
+    expect(div2).toBeInstanceOf(DocumentFragment)
+    expect(div2).not.toBe(root)
   })
 })