Files
piik/tests/client-gate-endpoint.test.ts
T
AAA 5781d6bbfa feat(client): complete native source and release boundary
Complete the Native Client source/audio boundary, strict v5 loopback contract, Browser media lifecycle handling, and non-blocking release checks. Keep unverified platform/physical gates explicit; do not rewrite the Go Server.
2026-09-04 03:42:54 +08:00

34 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { decodeClientEndpoint } from "../scripts/client-gate-endpoint";
describe("Client gate endpoint decoder", () => {
const endpoint = {
url: "http://127.0.0.1:39721",
host: "127.0.0.1:39721",
port: 39_721,
instanceToken: "a".repeat(43),
};
it("accepts the one exact loopback endpoint shape", () => {
expect(decodeClientEndpoint(JSON.stringify(endpoint))).toEqual(endpoint);
});
it("rejects partial, inconsistent, extended, and malformed endpoints", () => {
for (const value of [
{ ...endpoint, host: "localhost:39721" },
{ ...endpoint, port: 40_000 },
{ ...endpoint, instanceToken: "short" },
{ ...endpoint, extra: true },
{ port: endpoint.port, instanceToken: endpoint.instanceToken },
]) {
expect(() => decodeClientEndpoint(JSON.stringify(value))).toThrow(
"Client endpoint is invalid",
);
}
expect(() => decodeClientEndpoint("not-json")).toThrow(
"Client endpoint is invalid",
);
});
});