Skip to content

Commit

Permalink
test(ksuid): add epoch bounds tests (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 6, 2023
1 parent abbfc5a commit 052bcc7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/ksuid/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,19 @@ group("ksuid", {
id2: new Uint8Array([98, 25, 104, 28, 170, 213, 122, 63, 189, 122]),
});
},

"epoch bounds": () => {
assert.strictEqual(
defKSUID32().timeOnly(new Date("2156-10-20T18:54:55Z").getTime()),
"aWgEPLxxrZOFaOlDVFHTB3ZiQOO"
);
assert.throws(() =>
defKSUID32().timeOnly(new Date("2156-10-20T18:54:56Z").getTime())
);
// default epoch offset is approx. 2020-09-13,
// so earlier dates are unsupported in this case...
assert.throws(() =>
defKSUID32().timeOnly(new Date("1999-01-01").getTime())
);
},
});

0 comments on commit 052bcc7

Please sign in to comment.