From a68445bdac84b4c49ca926378bfe77f8a9e73fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Thu, 18 Apr 2024 01:30:56 +0800 Subject: [PATCH] test: add template abbreviation --- .../__tests__/abbreviation.spec.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 packages/compiler-vapor/__tests__/abbreviation.spec.ts diff --git a/packages/compiler-vapor/__tests__/abbreviation.spec.ts b/packages/compiler-vapor/__tests__/abbreviation.spec.ts new file mode 100644 index 000000000..2b52bd48e --- /dev/null +++ b/packages/compiler-vapor/__tests__/abbreviation.spec.ts @@ -0,0 +1,40 @@ +/** + * @vitest-environment jsdom + */ + +const parser = new DOMParser() + +function parseHTML(html: string) { + return parser.parseFromString(html, 'text/html').body.innerHTML +} + +function checkAbbr(template: string, abbrevation: string, expected: string) { + // TODO do some optimzations to make sure template === abbrevation + expect(parseHTML(abbrevation)).toBe(expected) +} + +test('template abbreviation', () => { + checkAbbr('
hello
', '
hello', '
hello
') + checkAbbr( + '
hello
', + '
hello', + '
hello
', + ) + checkAbbr( + '
foo
', + '
foo', + '
foo
', + ) + checkAbbr( + '

', + '

', + '

', + ) + checkAbbr( + '

', + '

', + '

', + ) + + checkAbbr('hello', 'hello', 'hello') +})