test(script/jsx): JSX fragment

This commit is contained in:
Elian Doran 2025-12-20 21:37:41 +02:00
parent 645557b505
commit dcd73ff9f9
No known key found for this signature in database

View File

@ -101,4 +101,24 @@ describe("JSX building", () => {
`;
expect(buildJsx(script).code).toStrictEqual(expected);
});
it("processes fragments", () => {
const script = trimIndentation`\
function MyComponent() {
return <>
<p>Hi</p>
<p>there</p>
</>;
}
`;
const expected = trimIndentation`\
const _jsxFileName = "";function MyComponent() {
return api.preact.h(api.preact.Fragment, null
, api.preact.h('p', {__self: this, __source: {fileName: _jsxFileName, lineNumber: 3}}, "Hi")
, api.preact.h('p', {__self: this, __source: {fileName: _jsxFileName, lineNumber: 4}}, "there")
);
}
`;
expect(buildJsx(script).code).toStrictEqual(expected);
});
});