UNPKG

@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.

69 lines (68 loc) 1.98 kB
/** * @module Cache */ import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest"; import { type ICache } from "../../../cache/contracts/_module.js"; import { type ITimeSpan } from "../../../time-span/contracts/time-span.contract.js"; import { type Promisable } from "../../../utilities/_module.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>; /** * @default false */ excludeEventTests?: boolean; /** * @default * ```ts * import { TimeSpan } from "@daiso-tech/core/time-span"; * * TimeSpan.fromMilliseconds(10) * ``` */ delayBuffer?: ITimeSpan; /** * @default * ```ts * import { TimeSpan } from "@daiso-tech/core/time-span" * * TimeSpan.fromMilliseconds(10) * ``` */ eventDispatchWaitTime?: ITimeSpan; }; /** * 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/memory-cache-adapter"; * 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;