Skip to content

Commit df1895c

Browse files
committed
Add tests for property-then-spread and spread-then-property
1 parent d27f465 commit df1895c

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

test/babel.test.mjs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('htm/babel', () => {
5656
).toBe(`h("a",foo,[]);`);
5757
});
5858

59-
test('spread a two variables', () => {
59+
test('spread two variables', () => {
6060
expect(
6161
transform('html`<a ...${foo} ...${bar}></a>`;', {
6262
babelrc: false,
@@ -70,6 +70,34 @@ describe('htm/babel', () => {
7070
).toBe(`h("a",Object.assign({},foo,bar),[]);`);
7171
});
7272

73+
test('property followed by a spread', () => {
74+
expect(
75+
transform('html`<a b="1" ...${foo}></a>`;', {
76+
babelrc: false,
77+
compact: true,
78+
plugins: [
79+
[htmBabelPlugin, {
80+
useBuiltIns: true
81+
}]
82+
]
83+
}).code
84+
).toBe(`h("a",Object.assign({b:"1"},foo),[]);`);
85+
});
86+
87+
test('spread followed by a property', () => {
88+
expect(
89+
transform('html`<a ...${foo} b="1"></a>`;', {
90+
babelrc: false,
91+
compact: true,
92+
plugins: [
93+
[htmBabelPlugin, {
94+
useBuiltIns: true
95+
}]
96+
]
97+
}).code
98+
).toBe(`h("a",Object.assign({},foo,{b:"1"}),[]);`);
99+
});
100+
73101
test('mix-and-match spreads', () => {
74102
expect(
75103
transform('html`<a b="1" ...${foo} c=${2} ...${{d:3}}></a>`;', {
@@ -83,7 +111,7 @@ describe('htm/babel', () => {
83111
}).code
84112
).toBe(`h("a",Object.assign({b:"1"},foo,{c:2},{d:3}),[]);`);
85113
});
86-
114+
87115
test('inline vnode transformation: (pragma:false)', () => {
88116
expect(
89117
transform('var name="world",vnode=html`<div id=hello>hello, ${name}</div>`;', {

0 commit comments

Comments
 (0)