Skip to content

Commit

Permalink
testing PR #7
Browse files Browse the repository at this point in the history
  • Loading branch information
4kimov committed Aug 30, 2023
1 parent 35511dc commit 02d6116
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/blocklist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,16 @@ test('match against a short blocklist word', () => {

expect.soft(sqids.decode(sqids.encode([1000]))).toEqual([1000]);
});

test('blocklist filtering in constructor', () => {
const sqids = new Sqids({
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
blocklist: new Set(['sqnmpn']) // lowercase blocklist in only-uppercase alphabet
});

let id = sqids.encode([1, 2, 3]);
let numbers = sqids.decode(id);

expect.soft(id).toEqual('ULPBZGBM'); // without blocklist, would've been "SQNMPN"
expect.soft(numbers).toEqual([1, 2, 3]);
});

0 comments on commit 02d6116

Please sign in to comment.