1 | import Hashids from '../lib/hashids'
|
2 |
|
3 | describe('min length', () => {
|
4 | const testMinLength = (minLength: number) => {
|
5 | const hashids = new Hashids('', minLength)
|
6 | const numbers = [1, 2, 3]
|
7 |
|
8 | const id = hashids.encode(numbers)
|
9 | const decodedNumbers = hashids.decode(id)
|
10 |
|
11 | expect(decodedNumbers).toEqual(numbers)
|
12 | expect([...id].length).toBeGreaterThanOrEqual(minLength)
|
13 | }
|
14 |
|
15 | test(`should work when 0`, () => {
|
16 | testMinLength(0)
|
17 | })
|
18 |
|
19 | test(`should work when 1`, () => {
|
20 | testMinLength(1)
|
21 | })
|
22 |
|
23 | test(`should work when 10`, () => {
|
24 | testMinLength(10)
|
25 | })
|
26 |
|
27 | test(`should work when 999`, () => {
|
28 | testMinLength(999)
|
29 | })
|
30 |
|
31 | test(`should work when 1000`, () => {
|
32 | testMinLength(1000)
|
33 | })
|
34 | })
|