Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. π« Status page with uptime monitoring & API monitoring as code π« openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.0 kB Β· 31 lines
TypeScript
1234567891011121314151617181920212223242526272829303132import { describe, expect, it } from "vitest";
import { parseCfRay } from "./cf-ray";
describe("parseCfRay", () => { it("resolves the data center from the iata code", () => { const result = parseCfRay("7d4b1f9e8c2a1234-CGB"); expect(result.status).toBe("success"); if (result.status === "success") { expect(result.data.code).toBe("CGB"); expect(result.data.location).toBe("CuiabΓ‘, Brazil"); } });
it("fails when the iata code is not in the list", () => { const result = parseCfRay("7d4b1f9e8c2a1234-ZZZ"); expect(result.status).toBe("failed"); if (result.status === "failed") { expect(result.error.message).toContain("ZZZ"); expect(result.error.message).toContain("not listed"); } });
it("fails when the header carries no iata code", () => { const result = parseCfRay("7d4b1f9e8c2a1234"); expect(result.status).toBe("failed"); if (result.status === "failed") { expect(result.error.message).toBe("Couldn't parse the header."); } });});