25 lines
711 B
TypeScript
25 lines
711 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { adminMutationNotice } from "@/lib/admin/notice";
|
|
|
|
describe("adminMutationNotice", () => {
|
|
it("maps a successful redirect to a safe notice", () => {
|
|
expect(adminMutationNotice({ saved: "1" })).toEqual({
|
|
tone: "ok",
|
|
label: "Saved",
|
|
message: "Changes were saved successfully.",
|
|
});
|
|
});
|
|
|
|
it("maps an error code without reflecting arbitrary query text", () => {
|
|
expect(adminMutationNotice({ error: "<script>" })).toEqual({
|
|
tone: "danger",
|
|
label: "Error",
|
|
message: "The operation could not be completed.",
|
|
});
|
|
});
|
|
|
|
it("returns null when there is no mutation result", () => {
|
|
expect(adminMutationNotice({})).toBeNull();
|
|
});
|
|
});
|