Skip to content

Commit a4fa39c

Browse files
committed
test(totp): add semantic assertions to epoch computation test
1 parent 2cc6eb9 commit a4fa39c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

packages/totp/src/index-test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,20 @@ export function createTOTPTests(ctx: TestContext<CryptoPlugin>): void {
328328
});
329329

330330
it("should compute epoch as timeStep * period + t0", async () => {
331+
const epoch = 1234567890;
332+
const period = 30;
333+
const t0 = 0;
331334
const result = await generate({
332335
secret,
333-
epoch: 1234567890,
334-
period: 30,
335-
t0: 0,
336+
epoch,
337+
period,
338+
t0,
336339
crypto,
337340
format: "detailed",
338341
});
339-
expect(result.epoch).toBe(result.timeStep * 30 + 0);
342+
expect(result.epoch).toBe(result.timeStep * period + t0);
343+
expect(result.epoch).toBeLessThanOrEqual(epoch);
344+
expect(result.epoch % period).toBe(0);
340345
});
341346

342347
it("should reflect custom t0 in epoch computation", async () => {

0 commit comments

Comments
 (0)