// Task 168 — per-tool emit assertion for graph-prune-denylist-remove.
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: ["ExistingLabel"] }),
    saveDenylist: vi.fn(),
}));
import { graphPruneDenylistRemove } from "../graph-prune-denylist-remove.js";
import * as graphPrune from "../../lib/graph-prune.js";
describe("graph-prune-denylist-remove — 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 graphPruneDenylistRemove(["ExistingLabel"]);
        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-remove");
        expect(body.line).toContain("result=ok");
    });
    it("emits result=error line when saveDenylist throws", async () => {
        vi.mocked(graphPrune.saveDenylist).mockImplementation(() => {
            throw new Error("permission denied");
        });
        await expect(graphPruneDenylistRemove(["ExistingLabel"])).rejects.toThrow(/permission denied/);
        expect(emit.fetchSpy).toHaveBeenCalledTimes(1);
        const body = emit.captures()[0];
        expect(body.level).toBe("error");
        expect(body.line).toContain("graph-prune-denylist-remove");
        expect(body.line).toContain("result=error");
    });
});
//# sourceMappingURL=graph-prune-denylist-remove-emit.test.js.map