feat: replace the ssr/client data blocks with apis blocks
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user