@sentzunhat/zacatl
Version:
A modular, high-performance TypeScript microservice framework for Node.js, featuring layered architecture, dependency injection, and robust validation for building scalable APIs and distributed systems.
36 lines (27 loc) • 934 B
text/typescript
import { describe, it, expect } from "vitest";
import { container } from "tsyringe";
import {
Domain,
ConfigDomain,
} from "../../../../../src/micro-service/architecture/domain";
class DummyProvider {
public value = "dummy";
}
class AnotherDummyProvider {
public name = "AnotherDummy";
}
describe("Domain", () => {
it("should register the provided domain providers in the DI container", () => {
const config: ConfigDomain = {
providers: [DummyProvider, AnotherDummyProvider],
};
const domain = new Domain(config);
domain.start();
const resolvedDummy = container.resolve(DummyProvider);
const resolvedAnother = container.resolve(AnotherDummyProvider);
expect(resolvedDummy).toBeInstanceOf(DummyProvider);
expect(resolvedAnother).toBeInstanceOf(AnotherDummyProvider);
expect(resolvedDummy.value).toBe("dummy");
expect(resolvedAnother.name).toBe("AnotherDummy");
});
});