mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
Updated the package version to 0.18.0-rc.4. Improved test logging by disabling console output during tests to reduce noise and enhance readability. Adjusted various test files to implement console log management, ensuring cleaner test outputs.
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { describe, vi, afterAll, beforeAll } from "vitest";
|
|
import { cacheWorkersKV } from "./cache";
|
|
import { viTestRunner } from "adapter/node/vitest";
|
|
import { cacheDriverTestSuite } from "core/drivers/cache/cache-driver-test-suite";
|
|
import { Miniflare } from "miniflare";
|
|
import { disableConsoleLog, enableConsoleLog } from "core/utils/test";
|
|
|
|
beforeAll(() => disableConsoleLog());
|
|
afterAll(() => enableConsoleLog());
|
|
|
|
describe("cacheWorkersKV", async () => {
|
|
beforeAll(() => {
|
|
vi.useFakeTimers();
|
|
});
|
|
afterAll(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
const mf = new Miniflare({
|
|
modules: true,
|
|
script: "export default { async fetch() { return new Response(null); } }",
|
|
kvNamespaces: ["KV"],
|
|
});
|
|
|
|
const kv = (await mf.getKVNamespace("KV")) as unknown as KVNamespace;
|
|
|
|
cacheDriverTestSuite(viTestRunner, {
|
|
makeCache: () => cacheWorkersKV(kv),
|
|
setTime: (ms: number) => {
|
|
vi.advanceTimersByTime(ms);
|
|
},
|
|
options: {
|
|
minTTL: 60,
|
|
// doesn't work with miniflare
|
|
skipTTL: true,
|
|
},
|
|
});
|
|
});
|