mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Add comprehensive unit tests for previously uncovered API lib modules, web stores, and plugin functions. Fix 2 pre-existing editor-store test failures (invertSelection mask values). Coverage: 30.3% -> 36.85% stmts (unit), 57.71% stmts (integration).
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatZodErrors } from "../../../apps/api/src/lib/errors.js";
|
|
|
|
describe("formatZodErrors", () => {
|
|
it("formats single issue with path", () => {
|
|
const result = formatZodErrors([
|
|
{ path: ["width"], message: "Must be positive", code: "custom" },
|
|
]);
|
|
expect(result).toBe("width: Must be positive");
|
|
});
|
|
|
|
it("formats single issue without path", () => {
|
|
const result = formatZodErrors([{ path: [], message: "Invalid input", code: "custom" }]);
|
|
expect(result).toBe("Invalid input");
|
|
});
|
|
|
|
it("joins multiple issues with semicolons", () => {
|
|
const result = formatZodErrors([
|
|
{ path: ["width"], message: "Required", code: "custom" },
|
|
{ path: ["height"], message: "Must be positive", code: "custom" },
|
|
]);
|
|
expect(result).toBe("width: Required; height: Must be positive");
|
|
});
|
|
|
|
it("returns empty string for empty array", () => {
|
|
const result = formatZodErrors([]);
|
|
expect(result).toBe("");
|
|
});
|
|
|
|
it("joins nested paths with dots", () => {
|
|
const result = formatZodErrors([
|
|
{ path: ["settings", "quality"], message: "Too high", code: "custom" },
|
|
]);
|
|
expect(result).toBe("settings.quality: Too high");
|
|
});
|
|
});
|