Skip to content

Commit 02e147a

Browse files
committed
Add props tests
1 parent 89f07cc commit 02e147a

File tree

1 file changed

+24
-0
lines changed
  • packages/babel-plugin-transform-jsx-to-tagged-templates/test

1 file changed

+24
-0
lines changed

packages/babel-plugin-transform-jsx-to-tagged-templates/test/index.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,30 @@ describe('babel-plugin-transform-jsx-to-tagged-templates', () => {
2424
).toBe('const Foo = () => html`<div class="foo" draggable>\n <h1>Hello</h1>\n <p>world.</p>\n</div>`;');
2525
});
2626

27+
describe('props', () => {
28+
test('static values', () => {
29+
expect(
30+
transform('(<div a="a" b="bb" c d />);', {
31+
babelrc: false,
32+
plugins: [
33+
transformJsxToTaggedTemplatesPlugin
34+
]
35+
}).code
36+
).toBe('html`<div a="a" b="bb" c d/>`;');
37+
});
38+
39+
test('expression values', () => {
40+
expect(
41+
transform('const Foo = (props, a) => <div a={a} b={"b"} c={{}} d={props.d} e />;', {
42+
babelrc: false,
43+
plugins: [
44+
transformJsxToTaggedTemplatesPlugin
45+
]
46+
}).code
47+
).toBe('const Foo = (props, a) => html`<div a=${a} b=${"b"} c=${{}} d=${props.d} e/>`;');
48+
});
49+
});
50+
2751
test('whitespace', () => {
2852
expect(
2953
transform('const Foo = props => <div a b> a <em> b </em> c <strong> d </strong> e </div>;', {

0 commit comments

Comments
 (0)