Skip to content

Commit

Permalink
Adding more timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Sep 21, 2023
1 parent 2fcb569 commit 7a3bf0c
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions test/lru.js
Expand Up @@ -170,16 +170,18 @@ describe("Testing functionality", function () {
const n1 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(typeof n1, "number", "Should be a number");
assert.strictEqual(n1 > 0, true, "Should be greater than zero");
this.cache.get(this.items[0]);
const n2 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(n1, n2, "Should be equal");
setTimeout(() => {
this.cache.set(this.items[0], false);
const n3 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(typeof n3, "number", "Should be a number");
assert.strictEqual(n3 > 0, true, "Should be greater than zero");
assert.strictEqual(n3 === n1, true, "Should be equal to the first expiration timestamp");
done();
this.cache.get(this.items[0]);
const n2 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(n1, n2, "Should be equal");
setTimeout(() => {
this.cache.set(this.items[0], false);
const n3 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(typeof n3, "number", "Should be a number");
assert.strictEqual(n3 > 0, true, "Should be greater than zero");
assert.strictEqual(n3 === n1, true, "Should be equal to the first expiration timestamp");
done();
}, 11);
}, 11);
});

Expand All @@ -189,16 +191,18 @@ describe("Testing functionality", function () {
const n1 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(typeof n1, "number", "Should be a number");
assert.strictEqual(n1, 0, "Should be zero");
this.cache.get(this.items[0]);
const n2 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(n1, n2, "Should be equal");
setTimeout(() => {
this.cache.set(this.items[0], false);
const n3 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(typeof n3, "number", "Should be a number");
assert.strictEqual(n3, 0, "Should be zero");
assert.strictEqual(n3 === n1, true, "Should be equal");
done();
this.cache.get(this.items[0]);
const n2 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(n1, n2, "Should be equal");
setTimeout(() => {
this.cache.set(this.items[0], false);
const n3 = this.cache.expiresAt(this.items[0]);
assert.strictEqual(typeof n3, "number", "Should be a number");
assert.strictEqual(n3, 0, "Should be zero");
assert.strictEqual(n3 === n1, true, "Should be equal");
done();
}, 11);
}, 11);
});

Expand Down

0 comments on commit 7a3bf0c

Please sign in to comment.