From 5bb65f1c440e35707cab97e3eb5a44aab0a7e475 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Fri, 4 Dec 2020 13:44:45 -0500 Subject: [PATCH] Add failing test for syntax error --- test/index.test.mjs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/index.test.mjs b/test/index.test.mjs index 640e055..9a4d345 100644 --- a/test/index.test.mjs +++ b/test/index.test.mjs @@ -26,7 +26,7 @@ describe('htm', () => { expect(html`
`).toEqual({ tag: 'div', props: null, children: [] }); expect(html``).toEqual({ tag: 'span', props: null, children: [] }); }); - + test('multiple root elements', () => { expect(html``).toEqual([ { tag: 'a', props: null, children: [] }, @@ -64,7 +64,7 @@ describe('htm', () => { test('single prop with static value', () => { expect(html``).toEqual({ tag: 'a', props: { href: '/hello' }, children: [] }); }); - + test('single prop with static value followed by a single boolean prop', () => { expect(html``).toEqual({ tag: 'a', props: { href: '/hello', b: true }, children: [] }); }); @@ -115,7 +115,7 @@ describe('htm', () => { test('multiple spread props in one element', () => { expect(html``).toEqual({ tag: 'a', props: { foo: 'bar', quux: 'baz' }, children: [] }); }); - + test('mixed spread + static props', () => { expect(html``).toEqual({ tag: 'a', props: { b: true, foo: 'bar' }, children: [] }); expect(html``).toEqual({ tag: 'a', props: { b: true, c: true, foo: 'bar' }, children: [] }); @@ -185,17 +185,17 @@ describe('htm', () => { test('hyphens (-) are allowed in attribute names', () => { expect(html``).toEqual(h('a', { 'b-c': true })); }); - + test('NUL characters are allowed in attribute values', () => { expect(html``).toEqual(h('a', { b: '\0' })); expect(html``).toEqual(h('a', { b: '\0', c: 'foo' })); }); - + test('NUL characters are allowed in text', () => { expect(html`\0`).toEqual(h('a', null, '\0')); expect(html`\0${'foo'}`).toEqual(h('a', null, '\0', 'foo')); }); - + test('cache key should be unique', () => { html``; expect(html``).toEqual(h('a', { b: '\0' })); @@ -215,4 +215,10 @@ describe('htm', () => { expect(html``).toEqual(h('a', null)); expect(html` Hello, world `).toEqual(h('a', null)); }); + + test('unclosed tag', () => { + expect(() => { + html`
`; + }).not.toThrow(); + }); });