Initial Move from Azure DevOps to GitHub

This commit is contained in:
Steve Faulkner
2020-05-25 21:30:55 -05:00
commit 36581fb6d9
986 changed files with 195242 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { ObjectCache } from "./ObjectCache";
describe("Object cache", () => {
it("should keep size at or below limit", () => {
const cache = new ObjectCache<number>(2);
cache.set("a", 1);
cache.set("b", 2);
cache.set("c", 3);
cache.set("d", 4);
expect(cache.size()).toBe(2);
});
it("should remove first added element to keep size at limit", () => {
const cache = new ObjectCache<number>(2);
cache.set("a", 1);
cache.set("b", 2);
cache.set("c", 3);
expect(cache.has("a")).toBe(false);
expect(cache.has("b")).toBe(true);
expect(cache.has("c")).toBe(true);
});
it("should remove first accessed element to keep size at limit", () => {
const cache = new ObjectCache<number>(2);
cache.set("a", 1);
cache.set("b", 2);
cache.get("a");
cache.set("c", 3);
expect(cache.has("a")).toBe(true);
expect(cache.has("b")).toBe(false);
expect(cache.has("c")).toBe(true);
});
});