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') +})