import { beforeEach, describe, expect, test } from "vitest";
import { MemoryCacheAdapter } from "@daiso-tech/core/cache/implementations/adapters";
import { Cache } from "@daiso-tech/core/cache/implementations/derivables";
import { EventBus } from "@daiso-tech/core/event-bus/implementations/derivables";
import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/implementations/adapters";
import { cacheTestSuite } from "@daiso-tech/core/cache/implementations/test-utilities";
describe("class: Cache", () => {
const eventBus = new EventBus<any>({
adapter: new MemoryEventBusAdapter({
rootGroup: "@global",
}),
});
let map: Map<string, unknown>;
beforeEach(() => {
map = new Map();
});
cacheTestSuite({
createCache: () =>
new Cache({
adapter: new MemoryCacheAdapter({
rootGroup: "@a",
map,
}),
eventBus,
}),
beforeEach,
describe,
expect,
test,
});
});
The cacheTestSuite function simplifies the process of testing your custom implementation of ICache with vitest.
IMPORT_PATH:
"@daiso-tech/core/cache/implementations/test-utilities"