feat(auth): add User, Cookie, Session entities + errors + config
This commit is contained in:
33
packages/auth/src/entities/user.test.ts
Normal file
33
packages/auth/src/entities/user.test.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user