@daiso-tech/core
Version:
The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.
47 lines (46 loc) • 1.44 kB
TypeScript
/**
* @module Cache
*/
import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest";
import { type ICache } from "../../../cache/contracts/_module-exports.js";
import { type Promisable } from "../../../utilities/_module-exports.js";
/**
*
* IMPORT_PATH: `"@daiso-tech/core/cache/test-utilities"`
* @group TestUtilities
*/
export type CacheTestSuiteSettings = {
expect: ExpectStatic;
test: TestAPI;
describe: SuiteAPI;
beforeEach: typeof beforeEach;
createCache: () => Promisable<ICache>;
};
/**
* The `cacheTestSuite` function simplifies the process of testing your custom implementation of {@link ICache | `ICache`} with `vitest`.
*
* IMPORT_PATH: `"@daiso-tech/core/cache/test-utilities"`
* @group TestUtilities
* @example
* ```ts
* import { beforeEach, describe, expect, test } from "vitest";
* import { cacheTestSuite } from "@daiso-tech/core/cache/test-utilities";
* import { MemoryCacheAdapter } from "@daiso-tech/core/cache/adapters";
* import { Cache } from "@daiso-tech/core/cache";
*
* describe("class: Cache", () => {
* cacheTestSuite({
* createCache: () => {
* return new Cache({
* adapter: new MemoryCacheAdapter(),
* });
* },
* test,
* beforeEach,
* expect,
* describe,
* });
* });
* ```
*/
export declare function cacheTestSuite(settings: CacheTestSuiteSettings): void;