Files
agentic-dev/packages/core-shared/src/di/bind-protocols.test.ts
Danijel Martinek ee069574ba fix: address final-review polish (docs + comments + test coverage)
- AGENTS.md bind-production code block: shows the slim default state
  (no @repo/core-events / @repo/core-realtime imports, BindProductionContext
  with no generic args) with a comment pointing to the scaffold workflow.
  The previous block showed a fully-wired post-scaffold state without
  signaling that none of those packages exist in main.
- bind-protocols.test.ts: top-of-file comment clarifies what these tests
  actually verify (protocol shapes have required methods) vs what the
  spec text might suggest (full assignability of optional packages'
  interfaces — that's verified by the e2e reconstruction tests, not here).
- core-package-generator.md: drops two stale "Until Phases 3-6 land"
  parentheticals — the phases shipped.
- config.test.ts: extends the choices assertion to cover all 4 names
  (realtime, events, trpc, ui).
- marketing-pages bind-* comments: reverse the inverted optional/required
  language. queue (IJobQueue) is from core-shared and always present;
  bus is the optional one (from @repo/core-events when scaffolded).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 15:01:40 +02:00

39 lines
1.4 KiB
TypeScript

import { describe, it, expectTypeOf } from "vitest";
import type {
EventBusProtocol,
RealtimeBroadcasterProtocol,
RealtimeRegistryProtocol,
} from "./bind-protocols";
// Protocol-shape tests. These verify each protocol type EXPORTS the
// expected method names. Full assignability of `IEventBus` /
// `IRealtimeBroadcaster` / `IRealtimeHandlerRegistry` to their respective
// protocols is verified at the optional-package level — when those packages
// are scaffolded back via `pnpm turbo gen core-package <name>`, the
// `extends`-link in their interface declarations forces a typecheck
// failure if the protocol surface ever drifts.
describe("EventBusProtocol", () => {
it("requires publish(event, payload) and subscribe(event, consumer, handler)", () => {
type Bus = EventBusProtocol;
expectTypeOf<Bus["publish"]>().toBeFunction();
expectTypeOf<Bus["subscribe"]>().toBeFunction();
});
});
describe("RealtimeBroadcasterProtocol", () => {
it("requires broadcast(channel, payload)", () => {
type Rt = RealtimeBroadcasterProtocol;
expectTypeOf<Rt["broadcast"]>().toBeFunction();
});
});
describe("RealtimeRegistryProtocol", () => {
it("requires register, registerChannel, listChannels", () => {
type Reg = RealtimeRegistryProtocol;
expectTypeOf<Reg["register"]>().toBeFunction();
expectTypeOf<Reg["registerChannel"]>().toBeFunction();
expectTypeOf<Reg["listChannels"]>().toBeFunction();
});
});