refactor: replace the legacy function runtime with shared
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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"');
|
||||
});
|
||||
Reference in New Issue
Block a user