diff options
author | 2022-01-21 16:28:25 -0800 | |
---|---|---|
committer | 2022-01-21 16:28:46 -0800 | |
commit | 40ff3e4618e33a4a76914fa25c6e1a8928686704 (patch) | |
tree | 7de3a58488d0dbdd1b9edb6118ade03c0f65a8a3 /integration/bunjs-only-snippets/transpiler.test.js | |
parent | c0a446df0209d4eed7107f86d5064cdc867a2263 (diff) | |
download | bun-40ff3e4618e33a4a76914fa25c6e1a8928686704.tar.gz bun-40ff3e4618e33a4a76914fa25c6e1a8928686704.tar.zst bun-40ff3e4618e33a4a76914fa25c6e1a8928686704.zip |
memory
Diffstat (limited to 'integration/bunjs-only-snippets/transpiler.test.js')
-rw-r--r-- | integration/bunjs-only-snippets/transpiler.test.js | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/integration/bunjs-only-snippets/transpiler.test.js b/integration/bunjs-only-snippets/transpiler.test.js index 8480dd091..34ec9f4aa 100644 --- a/integration/bunjs-only-snippets/transpiler.test.js +++ b/integration/bunjs-only-snippets/transpiler.test.js @@ -51,15 +51,42 @@ describe("Bun.Transpiler", () => { }); describe("transform", () => { + it("supports macros", async () => { + const out = await transpiler.transform(` + import {keepSecondArgument} from 'macro:${ + import.meta.dir + }/macro-check.js'; + + export default keepSecondArgument("Test failed", "Test passed"); + `); + expect(out.includes("Test failed")).toBe(false); + expect(out.includes("Test passed")).toBe(true); + + // ensure both the import and the macro function call are removed + expect(out.includes("keepSecondArgument")).toBe(false); + }); + + it("sync supports macros", async () => { + const out = transpiler.transformSync(` + import {keepSecondArgument} from 'macro:${ + import.meta.dir + }/macro-check.js'; + + export default keepSecondArgument("Test failed", "Test passed"); + `); + expect(out.includes("Test failed")).toBe(false); + expect(out.includes("Test passed")).toBe(true); + + expect(out.includes("keepSecondArgument")).toBe(false); + }); + it("removes types", () => { expect(code.includes("ActionFunction")).toBe(true); expect(code.includes("LoaderFunction")).toBe(true); - const out = transpiler.transformSync(code); expect(out.includes("ActionFunction")).toBe(false); expect(out.includes("LoaderFunction")).toBe(false); - const { exports } = transpiler.scan(out); expect(exports[0]).toBe("action"); |