aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/transpiler.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-21 20:00:12 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-09-21 20:00:12 -0700
commit37eee4235de88c708cdce1a200c39387da5bbee3 (patch)
tree12b9aed0daf4dbb870d514f4d21553824a469461 /test/bun.js/transpiler.test.js
parent871d530d6ab97699cd0d46637fabf84fdb74eb41 (diff)
downloadbun-37eee4235de88c708cdce1a200c39387da5bbee3.tar.gz
bun-37eee4235de88c708cdce1a200c39387da5bbee3.tar.zst
bun-37eee4235de88c708cdce1a200c39387da5bbee3.zip
Fix `preact` & other "classic" jsx transforms, most likely
Diffstat (limited to 'test/bun.js/transpiler.test.js')
-rw-r--r--test/bun.js/transpiler.test.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/bun.js/transpiler.test.js b/test/bun.js/transpiler.test.js
index 3d3bcc109..e10e4339f 100644
--- a/test/bun.js/transpiler.test.js
+++ b/test/bun.js/transpiler.test.js
@@ -317,6 +317,55 @@ describe("Bun.Transpiler", () => {
`;
+ it("jsxFactory (two level)", () => {
+ var bun = new Bun.Transpiler({
+ loader: "jsx",
+ allowBunRuntime: false,
+ tsconfig: JSON.stringify({
+ compilerOptions: {
+ jsxFragmentFactory: "foo.frag",
+ jsx: "react",
+ jsxFactory: "foo.factory",
+ },
+ }),
+ });
+
+ const element = bun.transformSync(`
+export default <div>hi</div>
+ `);
+
+ expect(element.includes("var jsxEl = foo.factory;")).toBe(true);
+
+ const fragment = bun.transformSync(`
+export default <>hi</>
+ `);
+ expect(fragment.includes("var JSXFrag = foo.frag,")).toBe(true);
+ });
+
+ it("jsxFactory (one level)", () => {
+ var bun = new Bun.Transpiler({
+ loader: "jsx",
+ allowBunRuntime: false,
+ tsconfig: JSON.stringify({
+ compilerOptions: {
+ jsxFragmentFactory: "foo.frag",
+ jsx: "react",
+ jsxFactory: "h",
+ },
+ }),
+ });
+
+ const element = bun.transformSync(`
+export default <div>hi</div>
+ `);
+ expect(element.includes("var jsxEl = h;")).toBe(true);
+
+ const fragment = bun.transformSync(`
+export default <>hi</>
+ `);
+ expect(fragment.includes("var JSXFrag = foo.frag,")).toBe(true);
+ });
+
it("JSX", () => {
var bun = new Bun.Transpiler({
loader: "jsx",