Files
bun-src/test/bundler/transpiler/template-literal.test.ts
2026-08-27 21:09:14 +00:00

23 lines
794 B
TypeScript

import { expect, test } from "bun:test";
import { bunEnv, bunExe } from "harness";
import { join } from "path";
// When targeting Bun's runtime,
// We must escape latin1 characters in raw template literals
// This is somewhat brittle
test("template literal", () => {
const { stdout, exitCode } = Bun.spawnSync({
cmd: [bunExe(), "run", join(import.meta.dir, "template-literal-fixture-test.js")],
env: bunEnv,
stdout: "pipe",
stderr: "inherit",
});
expect(exitCode).toBe(0);
expect(stdout.toString()).toBe(
// This is base64 encoded contents of the template literal
// this narrows down the test to the transpiler instead of the runtime
"8J+QsDEyMzEyM/CfkLDwn5Cw8J+QsPCfkLDwn5Cw8J+QsDEyM/CfkLAxMjPwn5CwMTIzMTIz8J+QsDEyM/CfkLAxMjPwn5CwLPCfkLB0cnVl",
);
});