Adjust tests to use vitest + jsdom

This commit is contained in:
Schluffe
2026-08-08 18:35:57 +02:00
parent ae8c63ce11
commit 9bdffd06e4
20 changed files with 196 additions and 150 deletions
+5 -4
View File
@@ -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);