import { describe, expect, it } from "vitest"; import { adminMutationNotice } from "./notice"; describe("adminMutationNotice", () => { it("returns a danger notice when there is an error", () => { expect(adminMutationNotice({ error: "boom" })).toEqual({ tone: "danger", label: "Error", message: "The operation could not be completed.", }); }); it("returns a success notice when saved is 1", () => { expect(adminMutationNotice({ saved: "1" })).toEqual({ tone: "ok", label: "Saved", message: "Changes were saved successfully.", }); }); it("returns null when nothing is set", () => { expect(adminMutationNotice({})).toBeNull(); }); it("prioritises errors over saved flags", () => { const notice = adminMutationNotice({ saved: "1", error: "x" }); expect(notice?.tone).toBe("danger"); }); });