import { describe, expect, test } from "bun:test";
import { createMetrics } from "@/metrics/index.js";
import { NoopMetrics } from "@/metrics/noop-recorder.js";
import { mockLogger } from "../_helpers/mock-logger.js";

describe("createMetrics", () => {
  test("returns NoopMetrics when disabled", () => {
    const m = createMetrics(
      {
        metricsEnabled: false,
        ddAgentHost: "localhost",
        ddDogstatsdPort: 8125,
        ddEnv: "test",
        provider: "cursor",
      },
      mockLogger(),
    );
    expect(m).toBeInstanceOf(NoopMetrics);
  });
  test("returns a real recorder when enabled", () => {
    const m = createMetrics(
      {
        metricsEnabled: true,
        ddAgentHost: "localhost",
        ddDogstatsdPort: 8125,
        ddEnv: "test",
        provider: "cursor",
      },
      mockLogger(),
    );
    expect(m).not.toBeInstanceOf(NoopMetrics);
    expect(() => m.increment("poll.executed", { poller: "jira" })).not.toThrow();
  });
});
