21 lines
845 B
TypeScript
21 lines
845 B
TypeScript
import { UNSAFE_decodeViaTurboStream as decodeViaTurboStream } from "react-router";
|
|
import { describe, expect, it } from "vitest";
|
|
import { singleFetchActionData } from "../tests/e2e/utils/navigation";
|
|
|
|
describe("singleFetchActionData", () => {
|
|
it("emits React Router's JSON-only v2 wire format without the standalone serializer", async () => {
|
|
const payload = {
|
|
fieldErrors: { email: undefined, password: "Synthetic password error" },
|
|
fields: { email: "login-contract@example.test" },
|
|
};
|
|
|
|
const result = await singleFetchActionData(payload, 400);
|
|
const body = new Response(result.body).body;
|
|
expect(body).not.toBeNull();
|
|
|
|
const decoded = await decodeViaTurboStream(body!, globalThis);
|
|
expect(decoded.value).toEqual({ data: payload });
|
|
await expect(decoded.done).resolves.toBeUndefined();
|
|
});
|
|
});
|