Skip to content

Commit c689574

Browse files
committed
feat: Mock the time when testing expiresAt
1 parent 3665f83 commit c689574

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,12 @@ describe("DynamoDBStore", () => {
234234
});
235235

236236
it("should set correct expiry when expiresIn option is set", async () => {
237+
const clock = sinon.useFakeTimers(1000000000);
237238
const storeWithExpiry = new DynamoDBStore({
238239
client: client,
239240
table: tableName,
240241
expiresIn: 1000
241242
});
242-
const beforeTime = Math.floor(Date.now() / 1000);
243243

244244
await new Promise((resolve, reject) => {
245245
storeWithExpiry.set(
@@ -263,8 +263,8 @@ describe("DynamoDBStore", () => {
263263
);
264264

265265
const expiryValue = parseInt(result.Item.expires.N);
266-
const expectedExpiry = beforeTime + 1000;
267-
expiryValue.should.be.approximately(expectedExpiry, 2);
266+
expiryValue.should.equal(1000000 + 1000);
267+
clock.restore();
268268
});
269269
});
270270

0 commit comments

Comments
 (0)