// Task 168 — per-tool emit assertion for graph-prune-denylist-add.
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
import { setupEmitCapture } from "./_helpers/emit-capture.js";
vi.mock("../../lib/graph-prune.js", () => ({
    resolveConfigDir: () => "/tmp/task-168-stub",
    loadDenylist: () => ({ values: [] }),
    saveDenylist: vi.fn(),
}));
import { graphPruneDenylistAdd } from "../graph-prune-denylist-add.js";
import * as graphPrune from "../../lib/graph-prune.js";
describe("graph-prune-denylist-add — emit wrapper wired", () => {
    let emit;
    beforeEach(() => {
        emit = setupEmitCapture();
        vi.mocked(graphPrune.saveDenylist).mockReset();
    });
    afterEach(() => emit.restore());
    it("emits result=ok line on happy path", async () => {
        await graphPruneDenylistAdd(["NewLabel"]);
        expect(emit.fetchSpy).toHaveBeenCalledTimes(1);
        const body = emit.captures()[0];
        expect(body.tag).toBe("mcp:memory");
        expect(body.level).toBe("info");
        expect(body.line).toContain("graph-prune-denylist-add");
        expect(body.line).toContain("result=ok");
    });
    it("emits result=error line when saveDenylist throws", async () => {
        vi.mocked(graphPrune.saveDenylist).mockImplementation(() => {
            throw new Error("disk full");
        });
        await expect(graphPruneDenylistAdd(["NewLabel"])).rejects.toThrow(/disk full/);
        expect(emit.fetchSpy).toHaveBeenCalledTimes(1);
        const body = emit.captures()[0];
        expect(body.level).toBe("error");
        expect(body.line).toContain("graph-prune-denylist-add");
        expect(body.line).toContain("result=error");
        expect(body.line).toContain("reason=neo4j-driver-error");
    });
});
//# sourceMappingURL=graph-prune-denylist-add-emit.test.js.map