@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.
68 lines (67 loc) • 2.48 kB
TypeScript
/**
* @module Semaphore
*/
import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest";
import { type ISemaphoreProvider } from "../../../semaphore/contracts/_module.js";
import { type ISerde } from "../../../serde/contracts/_module.js";
import { type Promisable } from "../../../utilities/_module.js";
/**
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/test-utilities"`
* @group Utilities
*/
export type SemaphoreProviderTestSuiteSettings = {
expect: ExpectStatic;
test: TestAPI;
describe: SuiteAPI;
beforeEach: typeof beforeEach;
createSemaphoreProvider: () => Promisable<{
semaphoreProvider: ISemaphoreProvider;
serde: ISerde;
}>;
/**
* @default true
*/
includeSerdeTests?: boolean;
/**
* @default true
*/
includeEventTests?: boolean;
};
/**
* The `semaphoreProviderTestSuite` function simplifies the process of testing your custom implementation of {@link ISemaphore | `ISemaphore`} with `vitest`.
*
* IMPORT_PATH: `"@daiso-tech/core/semaphore/test-utilities"`
* @group Utilities
* @example
* ```ts
* import { describe, expect, test, beforeEach } from "vitest";
* import { MemorySemaphoreAdapter } from "@daiso-tech/core/semaphore/memory-semaphore-adapter";
* import { SemaphoreProvider } from "@daiso-tech/core/semaphore";
* import { EventBus } from "@daiso-tech/core/event-bus";
* import { MemoryEventBusAdapter } from "@daiso-tech/core/event-bus/memory-event-bus-adapter";
* import { semaphoreProviderTestSuite } from "@daiso-tech/core/semaphore/test-utilities";
* import { Serde } from "@daiso-tech/core/serde";
* import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/super-json-serde-adapter";
* import type { ISemaphoreData } from "@daiso-tech/core/semaphore/contracts";
*
* describe("class: SemaphoreProvider", () => {
* semaphoreProviderTestSuite({
* createSemaphoreProvider: () => {
* const serde = new Serde(new SuperJsonSerdeAdapter());
* const semaphoreProvider = new SemaphoreProvider({
* serde,
* adapter: new MemorySemaphoreAdapter(),
* });
* return { semaphoreProvider, serde };
* },
* beforeEach,
* describe,
* expect,
* test,
* serde,
* });
* });
* ```
*/
export declare function semaphoreProviderTestSuite(settings: SemaphoreProviderTestSuiteSettings): void;