test(core,csr): replace text-substring agreement check with a behavioural one
The old assertions only searched REACTIVE_RUNTIME for substrings; they never touched buildApiRequest and were not anchored to the content-type line they claimed to guard, so they could not detect drift on either side. Replace with a fixture-driven test that runs both implementations on the same (path, method, input) cases and compares the actual request they produce. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { buildApiRequest } from "../src/api-request.ts";
|
||||
import { REACTIVE_RUNTIME } from "../../csr/src/reactive-runtime.ts";
|
||||
|
||||
test("GET builds a query string", () => {
|
||||
expect(buildApiRequest("/api/users", "GET", { name: "Ajay" }).url).toBe("/api/users?name=Ajay");
|
||||
@@ -47,9 +46,7 @@ test("values are encoded", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("the browser runtime and the shared builder agree", () => {
|
||||
// Cheap structural guard: the runtime must apply the same omission rule.
|
||||
// If someone changes one side's rules, this fails.
|
||||
expect(REACTIVE_RUNTIME).toContain('value === ""');
|
||||
expect(REACTIVE_RUNTIME).toContain("application/json");
|
||||
});
|
||||
// The behavioural agreement test between this builder and the browser
|
||||
// runtime's wrnexusCallApi lives in packages/csr/test/api-request-agreement.test.ts,
|
||||
// which can host the happy-dom harness needed to run the runtime and compare
|
||||
// outputs. This file has no DOM available.
|
||||
|
||||
Reference in New Issue
Block a user