From: 三咲智子 Kevin Deng Date: Sun, 26 Nov 2023 16:23:19 +0000 (+0800) Subject: test: fix template X-Git-Tag: v3.6.0-alpha.1~16^2~809 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df0f6275d4d4bfbdfb631e32e28eeb233e6feda8;p=thirdparty%2Fvuejs%2Fcore.git test: fix template --- diff --git a/packages/runtime-vapor/__tests__/template.spec.ts b/packages/runtime-vapor/__tests__/template.spec.ts index da471b4322..32ea085f07 100644 --- a/packages/runtime-vapor/__tests__/template.spec.ts +++ b/packages/runtime-vapor/__tests__/template.spec.ts @@ -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('
') - 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) }) })