/* @vitest-environment node */ import { describe, it, expect } from "vitest"; import { ApiClientError } from "@/lib/frontend/apiClient"; import { mapExplorerError } from "./errorMapping"; describe("lib/frontend/explorer/errorMapping", () => { it("maps unauthenticated", () => { const err = new ApiClientError({ status: 401, code: "AUTH_UNAUTHENTICATED", message: "Unauthorized", }); expect(mapExplorerError(err)?.kind).toBe("unauthenticated"); }); it("maps forbidden", () => { const err = new ApiClientError({ status: 403, code: "AUTH_FORBIDDEN_BRANCH", message: "Forbidden", }); expect(mapExplorerError(err)?.kind).toBe("forbidden"); }); it("maps not found", () => { const err = new ApiClientError({ status: 404, code: "FS_NOT_FOUND", message: "Not found", }); expect(mapExplorerError(err)?.kind).toBe("notfound"); }); it("maps unknown to generic", () => { expect(mapExplorerError(new Error("boom"))?.kind).toBe("generic"); }); });