Skip to content

Open-source status page, incident response and uptime monitoring

465 B
Raw Blame
import { describe, expect, it } from "vitest";

import { lenientEnum } from "./schemas";

describe("lenientEnum", () => {
  const schema = lenientEnum(["a", "b"]);

  it("keeps known values", () => {
    expect(schema.parse("a")).toBe("a");
  });

  it("parses unknown strings to unknown", () => {
    expect(schema.parse("brand_new_status")).toBe("unknown");
  });

  it("still rejects non-strings", () => {
    expect(() => schema.parse(42)).toThrow();
  });
});