import { describe, expect, it } from "vitest"; import { LiveModule } from "./live.module.js"; import { LiveDestinationRepository } from "./live-destination.repository.js"; import { GoLiveService } from "./go-live.service.js"; import { StreamOutputController } from "./stream-output.controller.js"; import { LiveDestinationController } from "./live-destination.controller.js"; import type { INestApplicationContext } from "@nestjs/common"; import { NestFactory } from "@nestjs/core"; /** * Module wiring smoke test: LiveModule is importable without a database (the * registry registration is env-gated) and provides its services/controllers * with the DI graph intact. */ describe("LiveModule wiring", () => { it("provides the repository, go-live service and controllers", async () => { const hadDatabaseUrl = process.env.DATABASE_URL; // registry registration is DB-gated; module must still construct delete process.env.DATABASE_URL; const app: INestApplicationContext = await NestFactory.createApplicationContext(LiveModule, { logger: false }); try { expect(app.get(LiveDestinationRepository)).toBeInstanceOf(LiveDestinationRepository); const goLive = app.get(GoLiveService, { strict: false }); expect(goLive).toBeInstanceOf(GoLiveService); expect(app.get(LiveDestinationController)).toBeInstanceOf(LiveDestinationController); expect(app.get(StreamOutputController)).toBeInstanceOf(StreamOutputController); } finally { await app.close(); if (hadDatabaseUrl !== undefined) process.env.DATABASE_URL = hadDatabaseUrl; } }); });