import { describe, expect, test } from "bun:test"; import { MemoryCacheStore } from "@/external/storage/cache/index.js"; import { CacheManager } from "@/utils/cacheUtils/CacheManager.js"; describe("CacheManager CacheStore adapter", () => { test("uses the provided CacheStore for get, set, del, and invalidate", async () => { const cacheStore = new MemoryCacheStore(); await CacheManager.setJson("cache-manager:test", { value: 1 }, 60, cacheStore); await expect( CacheManager.getJson<{ value: number }>("cache-manager:test", cacheStore), ).resolves.toEqual({ value: 1 }); await CacheManager.del("cache-manager:test", cacheStore); await expect(CacheManager.getJson("cache-manager:test", cacheStore)).resolves.toBeNull(); await CacheManager.setJson("otp:abc", { ok: true }, 60, cacheStore); await CacheManager.invalidate({ action: "otp", value: "abc", cacheStore }); await expect(CacheManager.getJson("otp:abc", cacheStore)).resolves.toBeNull(); }); });