48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { expect, test } from "bun:test";
|
|
import { parse } from "@wrnexus/syntax";
|
|
import { generateTargets } from "../src/targets.ts";
|
|
|
|
const SOURCE = `page Probe {
|
|
functions {
|
|
function unmarkedHelper() {
|
|
return "both";
|
|
}
|
|
|
|
client function clientOnly() {
|
|
return "browser";
|
|
}
|
|
|
|
server function serverOnly() {
|
|
return "server";
|
|
}
|
|
}
|
|
|
|
view { <main>x</main> }
|
|
}
|
|
`;
|
|
|
|
test("an unmarked function is emitted into both the browser and server modules", () => {
|
|
// This is the property the "legacy" runtime provided. Removing the variant
|
|
// must not change it.
|
|
const targets = generateTargets(parse(SOURCE));
|
|
|
|
expect(targets.browser).toContain("unmarkedHelper");
|
|
expect(targets.server).toContain("unmarkedHelper");
|
|
});
|
|
|
|
test("marked functions still go only where they belong", () => {
|
|
const targets = generateTargets(parse(SOURCE));
|
|
|
|
expect(targets.browser).toContain("clientOnly");
|
|
expect(targets.browser).not.toContain("serverOnly");
|
|
expect(targets.server).toContain("serverOnly");
|
|
expect(targets.server).not.toContain("clientOnly");
|
|
});
|
|
|
|
test("no emitted target mentions the removed legacy runtime", () => {
|
|
const targets = generateTargets(parse(SOURCE));
|
|
|
|
expect(targets.browser).not.toContain('"legacy"');
|
|
expect(targets.server).not.toContain('"legacy"');
|
|
});
|