min-length.js
713 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Hashids from '../lib/hashids';
import { assert } from 'chai';
describe('min length', () => {
const testMinLength = (minLength) => {
const hashids = new Hashids('', minLength);
const numbers = [1, 2, 3];
const id = hashids.encode(numbers);
const decodedNumbers = hashids.decode(id);
assert.deepEqual(decodedNumbers, numbers);
assert.isAtLeast(id.length, minLength);
};
it(`should work when 0`, () => {
testMinLength(0);
});
it(`should work when 1`, () => {
testMinLength(1);
});
it(`should work when 10`, () => {
testMinLength(10);
});
it(`should work when 999`, () => {
testMinLength(999);
});
it(`should work when 1000`, () => {
testMinLength(1000);
});
});