Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for special-cased component element names
  • Loading branch information
jviide committed Jul 3, 2019
commit b7f3feea229e2481b031e7bb2160f6d55a4c2610
48 changes: 48 additions & 0 deletions test/babel-transform-jsx.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ describe('babel-plugin-transform-jsx-to-htm', () => {
expect(
compile('(<div>a</div>);')
).toBe('html`<div>a</div>`;');

expect(
compile('(<div$ />);')
).toBe('html`<div$/>`;');

expect(
compile('(<div$>a</div$>);')
).toBe('html`<div$>a</div$>`;');

expect(
compile('(<div_ />);')
).toBe('html`<div_/>`;');

expect(
compile('(<div_>a</div_>);')
).toBe('html`<div_>a</div_>`;');
});

test('single component element', () => {
Expand All @@ -77,6 +93,38 @@ describe('babel-plugin-transform-jsx-to-htm', () => {
expect(
compile('(<Foo>a</Foo>);')
).toBe('html`<${Foo}>a</${Foo}>`;');

expect(
compile('(<$ />);')
).toBe('html`<${$}/>`;');

expect(
compile('(<$>a</$>);')
).toBe('html`<${$}>a</${$}>`;');

expect(
compile('(<_ />);')
).toBe('html`<${_}/>`;');

expect(
compile('(<_>a</_>);')
).toBe('html`<${_}>a</${_}>`;');

expect(
compile('(<_foo />);')
).toBe('html`<${_foo}/>`;');

expect(
compile('(<_foo>a</_foo>);')
).toBe('html`<${_foo}>a</${_foo}>`;');

expect(
compile('(<$foo />);')
).toBe('html`<${$foo}/>`;');

expect(
compile('(<$foo>a</$foo>);')
).toBe('html`<${$foo}>a</${$foo}>`;');
});

test('dotted component element', () => {
Expand Down