diff options
author | 2022-09-21 20:00:12 -0700 | |
---|---|---|
committer | 2022-09-21 20:00:12 -0700 | |
commit | 37eee4235de88c708cdce1a200c39387da5bbee3 (patch) | |
tree | 12b9aed0daf4dbb870d514f4d21553824a469461 /test/bun.js/transpiler.test.js | |
parent | 871d530d6ab97699cd0d46637fabf84fdb74eb41 (diff) | |
download | bun-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.js | 49 |
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", |