34 lines
786 B
TypeScript
34 lines
786 B
TypeScript
import { expect, test } from "bun:test";
|
|
import { parse } from "../src/index.ts";
|
|
|
|
test("an ssr data block is rejected and names the replacement", () => {
|
|
expect(() =>
|
|
parse(`page P {
|
|
ssr { api x GET /api/x { return users } }
|
|
view { <main>x</main> }
|
|
}
|
|
`),
|
|
).toThrow(/apis/);
|
|
});
|
|
|
|
test("a client data block is rejected and names the replacement", () => {
|
|
expect(() =>
|
|
parse(`page P {
|
|
client { api x GET /api/x { return users } }
|
|
view { <main>x</main> }
|
|
}
|
|
`),
|
|
).toThrow(/apis/);
|
|
});
|
|
|
|
test("client state is unaffected", () => {
|
|
// Different construct sharing the keyword. It must keep working.
|
|
const ast = parse(`page P {
|
|
client state { count = 0 }
|
|
view { <main>x</main> }
|
|
}
|
|
`);
|
|
|
|
expect(ast.states.some((state) => state.name === "count")).toBe(true);
|
|
});
|