Skip to content

Commit b7f3fee

Browse files
committed
Add tests for special-cased component element names
1 parent 60ef692 commit b7f3fee

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

test/babel-transform-jsx.test.mjs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ describe('babel-plugin-transform-jsx-to-htm', () => {
6767
expect(
6868
compile('(<div>a</div>);')
6969
).toBe('html`<div>a</div>`;');
70+
71+
expect(
72+
compile('(<div$ />);')
73+
).toBe('html`<div$/>`;');
74+
75+
expect(
76+
compile('(<div$>a</div$>);')
77+
).toBe('html`<div$>a</div$>`;');
78+
79+
expect(
80+
compile('(<div_ />);')
81+
).toBe('html`<div_/>`;');
82+
83+
expect(
84+
compile('(<div_>a</div_>);')
85+
).toBe('html`<div_>a</div_>`;');
7086
});
7187

7288
test('single component element', () => {
@@ -77,6 +93,38 @@ describe('babel-plugin-transform-jsx-to-htm', () => {
7793
expect(
7894
compile('(<Foo>a</Foo>);')
7995
).toBe('html`<${Foo}>a</${Foo}>`;');
96+
97+
expect(
98+
compile('(<$ />);')
99+
).toBe('html`<${$}/>`;');
100+
101+
expect(
102+
compile('(<$>a</$>);')
103+
).toBe('html`<${$}>a</${$}>`;');
104+
105+
expect(
106+
compile('(<_ />);')
107+
).toBe('html`<${_}/>`;');
108+
109+
expect(
110+
compile('(<_>a</_>);')
111+
).toBe('html`<${_}>a</${_}>`;');
112+
113+
expect(
114+
compile('(<_foo />);')
115+
).toBe('html`<${_foo}/>`;');
116+
117+
expect(
118+
compile('(<_foo>a</_foo>);')
119+
).toBe('html`<${_foo}>a</${_foo}>`;');
120+
121+
expect(
122+
compile('(<$foo />);')
123+
).toBe('html`<${$foo}/>`;');
124+
125+
expect(
126+
compile('(<$foo>a</$foo>);')
127+
).toBe('html`<${$foo}>a</${$foo}>`;');
80128
});
81129

82130
test('dotted component element', () => {

0 commit comments

Comments
 (0)