48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { getBetterAuthServerConfig } from "../convex/betterAuth/env";
|
|
|
|
test("getBetterAuthServerConfig requires BETTER_AUTH_SECRET", () => {
|
|
assert.throws(
|
|
() => getBetterAuthServerConfig({}),
|
|
/Missing BETTER_AUTH_SECRET/,
|
|
);
|
|
});
|
|
|
|
test("getBetterAuthServerConfig can use a placeholder secret for schema generation", () => {
|
|
const config = getBetterAuthServerConfig(
|
|
{},
|
|
{ allowMissingSecret: true },
|
|
);
|
|
|
|
assert.deepEqual(config, {
|
|
appUrl: "http://localhost:3000",
|
|
secret: "convex-better-auth-schema-generation-secret",
|
|
});
|
|
});
|
|
|
|
test("getBetterAuthServerConfig uses BETTER_AUTH_URL before NEXT_PUBLIC_APP_URL", () => {
|
|
const config = getBetterAuthServerConfig({
|
|
BETTER_AUTH_SECRET: "test-secret",
|
|
BETTER_AUTH_URL: "http://auth.local",
|
|
NEXT_PUBLIC_APP_URL: "http://app.local",
|
|
});
|
|
|
|
assert.deepEqual(config, {
|
|
appUrl: "http://auth.local",
|
|
secret: "test-secret",
|
|
});
|
|
});
|
|
|
|
test("getBetterAuthServerConfig falls back to local app URL", () => {
|
|
const config = getBetterAuthServerConfig({
|
|
BETTER_AUTH_SECRET: "test-secret",
|
|
});
|
|
|
|
assert.deepEqual(config, {
|
|
appUrl: "http://localhost:3000",
|
|
secret: "test-secret",
|
|
});
|
|
});
|