feat(navigation): add controller + tRPC router + header global + barrel
This commit is contained in:
28
packages/navigation/src/integrations/api/router.test.ts
Normal file
28
packages/navigation/src/integrations/api/router.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { navigationContainer } from "@/di/container";
|
||||
import { NAVIGATION_SYMBOLS } from "@/di/symbols";
|
||||
import { MockHeaderRepository } from "@/infrastructure/repositories/mock-header.repository";
|
||||
import type { IHeaderRepository } from "@/application/repositories/header-repository.interface";
|
||||
import { navigationRouter } from "./router";
|
||||
|
||||
describe("navigationRouter", () => {
|
||||
beforeEach(() => {
|
||||
if (navigationContainer.isBound(NAVIGATION_SYMBOLS.IHeaderRepository)) {
|
||||
navigationContainer.unbind(NAVIGATION_SYMBOLS.IHeaderRepository);
|
||||
}
|
||||
navigationContainer
|
||||
.bind<IHeaderRepository>(NAVIGATION_SYMBOLS.IHeaderRepository)
|
||||
.toConstantValue(new MockHeaderRepository());
|
||||
});
|
||||
|
||||
it("exposes header procedure", () => {
|
||||
const names = Object.keys(navigationRouter._def.procedures);
|
||||
expect(names).toContain("header");
|
||||
});
|
||||
|
||||
it("header returns 3 items", async () => {
|
||||
const caller = navigationRouter.createCaller({});
|
||||
const result = await caller.header();
|
||||
expect(result.items).toHaveLength(3);
|
||||
});
|
||||
});
|
||||
8
packages/navigation/src/integrations/api/router.ts
Normal file
8
packages/navigation/src/integrations/api/router.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { router, publicProcedure } from "@repo/core-shared/trpc/init";
|
||||
import { getHeaderController } from "../../interface-adapters/controllers/header.controller";
|
||||
|
||||
export const navigationRouter = router({
|
||||
header: publicProcedure.query(() => getHeaderController()),
|
||||
});
|
||||
|
||||
export type NavigationRouter = typeof navigationRouter;
|
||||
Reference in New Issue
Block a user