feat(navigation): add Header entity + use-case + mock/payload repos + DI container
This commit is contained in:
24
packages/navigation/src/di/container.test.ts
Normal file
24
packages/navigation/src/di/container.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { navigationContainer } from "./container";
|
||||
import { NAVIGATION_SYMBOLS } from "./symbols";
|
||||
import { NavigationModule } from "./module";
|
||||
import { MockHeaderRepository } from "@/infrastructure/repositories/mock-header.repository";
|
||||
import type { IHeaderRepository } from "@/application/repositories/header-repository.interface";
|
||||
|
||||
describe("navigationContainer", () => {
|
||||
beforeEach(() => {
|
||||
navigationContainer.unbindAll();
|
||||
navigationContainer.load(NavigationModule);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
navigationContainer.unbindAll();
|
||||
});
|
||||
|
||||
it("resolves IHeaderRepository to MockHeaderRepository", () => {
|
||||
const repo = navigationContainer.get<IHeaderRepository>(
|
||||
NAVIGATION_SYMBOLS.IHeaderRepository,
|
||||
);
|
||||
expect(repo).toBeInstanceOf(MockHeaderRepository);
|
||||
});
|
||||
});
|
||||
6
packages/navigation/src/di/container.ts
Normal file
6
packages/navigation/src/di/container.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import "reflect-metadata";
|
||||
import { Container } from "inversify";
|
||||
import { NavigationModule } from "./module";
|
||||
|
||||
export const navigationContainer = new Container({ defaultScope: "Singleton" });
|
||||
navigationContainer.load(NavigationModule);
|
||||
11
packages/navigation/src/di/module.ts
Normal file
11
packages/navigation/src/di/module.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ContainerModule, type interfaces } from "inversify";
|
||||
|
||||
import type { IHeaderRepository } from "../application/repositories/header-repository.interface";
|
||||
import { MockHeaderRepository } from "../infrastructure/repositories/mock-header.repository";
|
||||
import { NAVIGATION_SYMBOLS } from "./symbols";
|
||||
|
||||
export const NavigationModule = new ContainerModule((bind: interfaces.Bind) => {
|
||||
bind<IHeaderRepository>(NAVIGATION_SYMBOLS.IHeaderRepository).to(
|
||||
MockHeaderRepository,
|
||||
);
|
||||
});
|
||||
3
packages/navigation/src/di/symbols.ts
Normal file
3
packages/navigation/src/di/symbols.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const NAVIGATION_SYMBOLS = {
|
||||
IHeaderRepository: Symbol.for("navigation:IHeaderRepository"),
|
||||
} as const;
|
||||
Reference in New Issue
Block a user