eletrotupi / tcc/ api/tests/auth/password-reset-token.unit.test.tsaaca724b6020e9a1b82acb9cc3bb90f81951dc21
476 B | 16 lines Raw
1
import { describe, it, expect } from 'vitest'
2
import { generatePasswordResetToken } from '@app/lib/jwt'
3

4
describe('generatePasswordResetToken', () => {
5
  it('produces an opaque 64-character hex token', () => {
6
    expect(generatePasswordResetToken()).toMatch(/^[0-9a-f]{64}$/)
7
  })
8

9
  it('does not repeat across draws', () => {
10
    const tokens = new Set(
11
      Array.from({ length: 100 }, () => generatePasswordResetToken()),
12
    )
13

14
    expect(tokens.size).toBe(100)
15
  })
16
})