Raw
1 import {
2 generateVerificationToken,
3 getVerificationTokenTtlMs,
4 hashVerificationToken,
5 } from "../verification-token"
6
7 describe("verification-token utils", () => {
8 it("generates opaque tokens and stable hashes", () => {
9 const token = generateVerificationToken()
10
11 expect(token).toEqual(expect.any(String))
12 expect(hashVerificationToken(token)).toMatch(/^[a-f0-9]{64}$/)
13 expect(hashVerificationToken(token)).toEqual(hashVerificationToken(token))
14 })
15
16 it("converts ttl seconds to milliseconds", () => {
17 expect(getVerificationTokenTtlMs(60)).toEqual(60_000)
18 })
19 })