import { describe, it, expect } from "vitest";
import { RecordingTracer, RecordingLogger } from "@repo/core-testing/instrumentation";
import { MockHeaderRepository } from "@/infrastructure/repositories/header.repository.mock";

// Mock repo also wraps in spans (R42).
describe("MockHeaderRepository emits spans (R42)", () => {
  it("getHeader emits one span with op='repository'", async () => {
    const tracer = new RecordingTracer();
    const logger = new RecordingLogger();
    const repo = new MockHeaderRepository(undefined, tracer, logger);
    await repo.getHeader();
    expect(tracer.spans).toHaveLength(1);
    expect(tracer.spans[0]).toMatchObject({
      name: "header.getHeader",
      op: "repository",
    });
    expect(typeof tracer.spans[0]!.attributes.itemCount).toBe("number");
  });
});
