Files
EpicNext-Cms/src/lib/admin/notice.test.ts
T
openhands 82e8448f26 test: add unit tests for pure logic modules
Add 22 test files covering imager, soundtracks, browser-headers, source-keys (figure/pet/effect), effect-source, plus catalog-translations, catalog-layouts, client-translation-files, translations-utils, and various admin/services/helpers modules. Total test count increases by 120+.
2026-08-07 18:53:59 +02:00

27 lines
828 B
TypeScript

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");
});
});