Files
radicle-explorer/tests/unit/cache.test.ts
T
2022-12-22 16:46:08 +01:00

14 lines
448 B
TypeScript

import { cached } from "@app/lib/cache";
import { expect, test, vi } from "vitest";
test("it caches undefined return values", async () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const inner = vi.fn(async (_: string) => undefined);
const memoized = cached(inner, key => key);
expect(await memoized("a")).toBe(undefined);
expect(await memoized("a")).toBe(undefined);
expect(inner).toHaveBeenCalledTimes(1);
});