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.

60 lines (59 loc) 2.02 kB
/** * @module Lock */ import { type TestAPI, type SuiteAPI, type ExpectStatic, type beforeEach } from "vitest"; import { type IDatabaseLockAdapter } from "../../../lock/contracts/_module-exports.js"; import { type Promisable } from "../../../utilities/_module-exports.js"; /** * * IMPORT_PATH: `"@daiso-tech/core/lock/test-utilities"` * @group Utilities */ export type DatabaseLockAdapterTestSuiteSettings = { expect: ExpectStatic; test: TestAPI; describe: SuiteAPI; beforeEach: typeof beforeEach; createAdapter: () => Promisable<IDatabaseLockAdapter>; }; /** * The `databaseLockAdapterTestSuite` function simplifies the process of testing your custom implementation of {@link IDatabaseLockAdapter | `IDatabaseLockAdapter`} with `vitest`. * * IMPORT_PATH: `"@daiso-tech/core/lock/test-utilities"` * @group Utilities * @example * ```ts * import { afterEach, beforeEach, describe, expect, test } from "vitest"; * import { databaseLockAdapterTestSuite } from "@daiso-tech/core/lock/test-utilities"; * import { LibsqlLockAdapter } from "@daiso-tech/core/lock/adapters"; * import { type Client, createClient } from "@libsql/client"; * * describe("class: LibsqlLockAdapter", () => { * let client: Client; * beforeEach(() => { * client = createClient({ * url: ":memory:", * }); * }); * afterEach(() => { * client.close(); * }); * databaseLockAdapterTestSuite({ * createAdapter: async () => { * const lockAdapter = new LibsqlLockAdapter({ * database: client, * tableName: "custom_table", * shouldRemoveExpiredKeys: false, * }); * await lockAdapter.init(); * return lockAdapter; * }, * test, * beforeEach, * expect, * describe, * }); * }); * ``` */ export declare function databaseLockAdapterTestSuite(settings: DatabaseLockAdapterTestSuiteSettings): void;