Skip to content

Commit 5bb65f1

Browse files
committed
Add failing test for syntax error
1 parent aefd98d commit 5bb65f1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test/index.test.mjs

+12-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('htm', () => {
2626
expect(html`<div/>`).toEqual({ tag: 'div', props: null, children: [] });
2727
expect(html`<span />`).toEqual({ tag: 'span', props: null, children: [] });
2828
});
29-
29+
3030
test('multiple root elements', () => {
3131
expect(html`<a /><b></b><c><//>`).toEqual([
3232
{ tag: 'a', props: null, children: [] },
@@ -64,7 +64,7 @@ describe('htm', () => {
6464
test('single prop with static value', () => {
6565
expect(html`<a href="/hello" />`).toEqual({ tag: 'a', props: { href: '/hello' }, children: [] });
6666
});
67-
67+
6868
test('single prop with static value followed by a single boolean prop', () => {
6969
expect(html`<a href="/hello" b />`).toEqual({ tag: 'a', props: { href: '/hello', b: true }, children: [] });
7070
});
@@ -115,7 +115,7 @@ describe('htm', () => {
115115
test('multiple spread props in one element', () => {
116116
expect(html`<a ...${{ foo: 'bar' }} ...${{ quux: 'baz' }} />`).toEqual({ tag: 'a', props: { foo: 'bar', quux: 'baz' }, children: [] });
117117
});
118-
118+
119119
test('mixed spread + static props', () => {
120120
expect(html`<a b ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: true, foo: 'bar' }, children: [] });
121121
expect(html`<a b c ...${{ foo: 'bar' }} />`).toEqual({ tag: 'a', props: { b: true, c: true, foo: 'bar' }, children: [] });
@@ -185,17 +185,17 @@ describe('htm', () => {
185185
test('hyphens (-) are allowed in attribute names', () => {
186186
expect(html`<a b-c></a>`).toEqual(h('a', { 'b-c': true }));
187187
});
188-
188+
189189
test('NUL characters are allowed in attribute values', () => {
190190
expect(html`<a b="\0"></a>`).toEqual(h('a', { b: '\0' }));
191191
expect(html`<a b="\0" c=${'foo'}></a>`).toEqual(h('a', { b: '\0', c: 'foo' }));
192192
});
193-
193+
194194
test('NUL characters are allowed in text', () => {
195195
expect(html`<a>\0</a>`).toEqual(h('a', null, '\0'));
196196
expect(html`<a>\0${'foo'}</a>`).toEqual(h('a', null, '\0', 'foo'));
197197
});
198-
198+
199199
test('cache key should be unique', () => {
200200
html`<a b="${'foo'}" />`;
201201
expect(html`<a b="\0" />`).toEqual(h('a', { b: '\0' }));
@@ -215,4 +215,10 @@ describe('htm', () => {
215215
expect(html`<a><!-- ${'Hello, world!'} --></a>`).toEqual(h('a', null));
216216
expect(html`<a><!--> Hello, world <!--></a>`).toEqual(h('a', null));
217217
});
218+
219+
test('unclosed tag', () => {
220+
expect(() => {
221+
html`<div<div></div></div>`;
222+
}).not.toThrow();
223+
});
218224
});

0 commit comments

Comments
 (0)