Files
webdev-pipeline/tests/better-auth-component.test.ts

46 lines
1.1 KiB
TypeScript

import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import test from "node:test";
test("local Better Auth component exports adapter functions", async () => {
const source = await readFile(
join(process.cwd(), "convex/betterAuth/adapter.ts"),
"utf8",
);
for (const exportName of [
"create",
"findOne",
"findMany",
"updateOne",
"updateMany",
"deleteOne",
"deleteMany",
]) {
assert.match(source, new RegExp(`\\b${exportName}\\b`));
}
assert.match(source, /createApi\(schema, createSchemaAuthOptions\)/);
});
test("Better Auth email/password signup is disabled server-side", async () => {
const source = await readFile(
join(process.cwd(), "convex/betterAuth/auth.ts"),
"utf8",
);
assert.match(source, /disableSignUp:\s*true/);
});
test("auth entry only exposes sign in", async () => {
const source = await readFile(
join(process.cwd(), "components/auth-entry.tsx"),
"utf8",
);
assert.doesNotMatch(source, /signUp/);
assert.doesNotMatch(source, /Account anlegen/);
assert.match(source, /authClient\.signIn\.email/);
});