Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

694 B
Raw Blame
import { expect, test } from "vitest";
import {
  AuthorizationError,
  PlanRequiredError,
  createErrorResponse,
} from "./errors.server";

test("creates authorization and plan-required errors", () => {
  expect(new AuthorizationError("No access").message).toBe("No access");

  const error = new PlanRequiredError("Upgrade required");
  expect(error.message).toBe("Upgrade required");
  expect(error.code).toBe("PLAN_REQUIRED");
});

test("creates serializable error responses", () => {
  expect(createErrorResponse(new Error("Failed"))).toEqual({
    success: false,
    error: "Failed",
  });
  expect(createErrorResponse("Nope")).toEqual({
    success: false,
    error: "Nope",
  });
});