min-length.js 713 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Hashids from '../lib/hashids';
  2. import { assert } from 'chai';
  3. describe('min length', () => {
  4. const testMinLength = (minLength) => {
  5. const hashids = new Hashids('', minLength);
  6. const numbers = [1, 2, 3];
  7. const id = hashids.encode(numbers);
  8. const decodedNumbers = hashids.decode(id);
  9. assert.deepEqual(decodedNumbers, numbers);
  10. assert.isAtLeast(id.length, minLength);
  11. };
  12. it(`should work when 0`, () => {
  13. testMinLength(0);
  14. });
  15. it(`should work when 1`, () => {
  16. testMinLength(1);
  17. });
  18. it(`should work when 10`, () => {
  19. testMinLength(10);
  20. });
  21. it(`should work when 999`, () => {
  22. testMinLength(999);
  23. });
  24. it(`should work when 1000`, () => {
  25. testMinLength(1000);
  26. });
  27. });