import { describe, expect, test } from "bun:test";
import { FakeMetrics } from "../_helpers/fake-metrics.js";

describe("FakeMetrics", () => {
  test("captures calls and supports querying by name", () => {
    const m = new FakeMetrics();
    m.increment("poll.executed", { poller: "jira" });
    m.increment("poll.skipped", { poller: "jira", reason: "busy" });
    m.gauge("queue.depth", 4);

    expect(m.calls).toHaveLength(3);
    expect(m.countOf("poll.executed")).toBe(1);
    expect(m.last("queue.depth")).toEqual({
      kind: "gauge",
      name: "queue.depth",
      value: 4,
      tags: undefined,
    });
    expect(m.tagsOf("poll.skipped")[0]).toEqual({ poller: "jira", reason: "busy" });
  });
});
