change(web): adjusts unit tests per review

This commit is contained in:
Joshua Horton 2025-08-18 12:00:23 -05:00
parent 222fa814ac
commit 3e9e638f9d
2 changed files with 9 additions and 10 deletions

View file

@ -57,7 +57,7 @@ export class RewindableCache<Key, Value> {
get(key: Key): Value {
const set = this.cacheOrderSet;
if(!set.has(key)) {
return null;
return undefined;
}
set.delete(key);

View file

@ -87,11 +87,10 @@ describe("RewindableCache", () => {
const cache = new RewindableCache(2);
cache.add(1, 'a');
cache.add(2, 'b');
cache.add(3, 'c');
cache.add(4, 'd');
cache.add(5, 'e');
cache.add(3, 'c'); // Entry 1 no longer valid
cache.add(4, 'd'); // 2
cache.add(5, 'e'); // 3
assert.doesNotThrow(() => cache.get(2));
assert.throws(() => cache.rewindTo(3));
});
@ -99,11 +98,11 @@ describe("RewindableCache", () => {
const cache = new RewindableCache(2);
cache.add(1, 'a');
cache.add(2, 'b');
cache.add(3, 'c');
cache.add(4, 'd');
cache.add(5, 'e');
cache.add(3, 'c'); // Entry 1 no longer valid
cache.add(4, 'd'); // 2
cache.add(5, 'e'); // 3
assert.doesNotThrow(() => cache.peek(2));
assert.doesNotThrow(() => cache.get(2));
assert.isUndefined(cache.peek(2), 'outdated cache entry should be forgotten');
assert.isUndefined(cache.get(2), 'outdated cache entry should be forgotten');
});
});