feat(auth): add User, Cookie, Session entities + errors + config

This commit is contained in:
2026-05-05 00:38:49 +02:00
parent 54dc9d33d5
commit ceffd05063
7 changed files with 113 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { describe, expect, it } from "vitest";
import { userSchema } from "./user";
describe("userSchema", () => {
it("accepts a valid user", () => {
const result = userSchema.parse({
id: "1",
username: "alice",
passwordHash: "hashed_password_1",
});
expect(result.username).toBe("alice");
});
it("rejects username shorter than 3 chars", () => {
expect(() =>
userSchema.parse({
id: "1",
username: "ab",
passwordHash: "hashed_password_1",
}),
).toThrow();
});
it("rejects passwordHash shorter than 6 chars", () => {
expect(() =>
userSchema.parse({
id: "1",
username: "alice",
passwordHash: "abc",
}),
).toThrow();
});
});