Skip to content

Build your personal knowledge base with Trilium Notes

test(script/jsx): JSX fragment

Elian Dorandcd73ff9f9d8
diff --git a/apps/server/src/services/script.spec.ts b/apps/server/src/services/script.spec.ts
index 5ae13bbd75..ec9158b1d8 100644
--- a/apps/server/src/services/script.spec.ts
+++ b/apps/server/src/services/script.spec.ts
@@ -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);
+ });
});