Files
pitchfast/tests/auth-server-jwt-cache.test.ts
2026-06-05 17:04:03 +02:00

24 lines
862 B
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";
const authServerPath = join(process.cwd(), "lib", "auth-server.ts");
test("server auth utilities reuse valid Convex JWT cookies", async () => {
const source = await readFile(authServerPath, "utf8");
assert.match(source, /jwtCache:\s*\{/);
assert.match(source, /enabled:\s*true/);
assert.match(source, /isAuthError:\s*isConvexAuthError/);
});
test("server auth error predicate keeps stale token refresh possible", async () => {
const source = await readFile(authServerPath, "utf8");
assert.match(source, /function isConvexAuthError\(error: unknown\): boolean/);
assert.match(source, /Unauthenticated/);
assert.match(source, /Unauthorized/);
assert.doesNotMatch(source, /InvalidToken/);
});