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.1 kB ยท 31 lines
TypeScript
1234567891011121314151617181920212223242526272829303132import { describe, expect, it } from "vitest";
import { parseFlyRequestId } from "./fly-request-id";
describe("parseFlyRequestId", () => { it("resolves the region from the trailing iata code", () => { const result = parseFlyRequestId("01h2abcxyz9876-ams"); expect(result.status).toBe("success"); if (result.status === "success") { expect(result.data.code).toBe("ams"); expect(result.data.location).toBe("Amsterdam, Netherlands"); } });
it("fails when the region is not in the list", () => { const result = parseFlyRequestId("01h2abcxyz9876-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 region code", () => { const result = parseFlyRequestId("0123456789"); expect(result.status).toBe("failed"); if (result.status === "failed") { expect(result.error.message).toBe("Couldn't parse the header."); } });});