eletrotupi / tcc/ api/tests/auth/activation-code.unit.test.tsaaca724b6020e9a1b82acb9cc3bb90f81951dc21
555 B | 18 lines Raw
1
import { describe, it, expect } from 'vitest'
2
import { generateActivationCode } from '@app/services/auth.service'
3

4
describe('generateActivationCode', () => {
5
  it('produces exactly six decimal digits on every draw', () => {
6
    const codes = Array.from({ length: 500 }, () => generateActivationCode())
7

8
    for (const code of codes) {
9
      expect(code).toMatch(/^\d{6}$/)
10
    }
11
  })
12

13
  it('reaches the digit nine', () => {
14
    const digits = Array.from({ length: 500 }, () => generateActivationCode()).join('')
15

16
    expect(digits).toContain('9')
17
  })
18
})