Adjust tests to use vitest + jsdom
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { expect, test, vi } from "vitest";
|
||||
import { type Cache, memoize, withCache } from "#/engine/lib/cache.ts";
|
||||
import { type Cache, memoize, withCache } from "./cache.ts";
|
||||
|
||||
test("withCache", () => {
|
||||
const cache: Cache<number> = new Map();
|
||||
@@ -31,10 +31,11 @@ test("async withCache", async () => {
|
||||
const callback = withCache(fn, cache);
|
||||
|
||||
const one = "1";
|
||||
const res = await callback("one", one);
|
||||
const _ = await callback("one", one);
|
||||
const res = callback("one", one);
|
||||
const _ = callback("one", one);
|
||||
|
||||
expect(res).toBe(1);
|
||||
expect(res).toBe(_);
|
||||
expect(await res).toBe(1);
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(await callback("two", "2")).toBe(2);
|
||||
|
||||
Reference in New Issue
Block a user