Files
kai b0d0357d95
release / which version (push) Successful in 1s
release / olares chart · sanity (push) Successful in 4s
release / app (push) Successful in 57s
release / tag and release (push) Successful in 2s
Children's accounts: unlocked device, picture and PIN (26.11.9) (#10)
2026-11-06 22:44:45 +00:00

22 lines
754 B
TypeScript

import { describe, expect, it } from "vitest";
import { hashPin, isValidPin, verifyPin } from "@/lib/auth/pin";
describe("pin", () => {
it("hashes with salt and verifies only the right PIN", async () => {
const a = await hashPin("4711");
const b = await hashPin("4711");
expect(a).not.toBe(b);
expect(a).not.toContain("4711");
expect(await verifyPin("4711", a)).toBe(true);
expect(await verifyPin("4712", a)).toBe(false);
expect(await verifyPin("4711", null)).toBe(false);
expect(await verifyPin("4711", "kaputt")).toBe(false);
});
it("accepts exactly four digits", () => {
expect(isValidPin("0042")).toBe(true);
expect(isValidPin("123")).toBe(false);
expect(isValidPin("12a4")).toBe(false);
});
});