import { describe, expect, test, beforeEach } from "vitest";
import { MemorySemaphoreAdapter } from "@daiso-tech/core/semaphore/memory-semaphore-adapter";
import { SemaphoreFactory } 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 { semaphoreFactoryTestSuite } 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: SemaphoreFactory", () => {
semaphoreFactoryTestSuite({
createSemaphoreFactory: () => {
const serde = new Serde(new SuperJsonSerdeAdapter());
const semaphoreFactory = new SemaphoreFactory({
serde,
adapter: new MemorySemaphoreAdapter(),
});
return { semaphoreFactory, serde };
},
beforeEach,
describe,
expect,
test,
serde,
});
});
The
semaphoreFactoryTestSuitefunction simplifies the process of testing your custom implementation ofISemaphorewithvitest.IMPORT_PATH:
"@daiso-tech/core/semaphore/test-utilities"