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.8 kB ยท 56 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import { expect } from "@std/expect";import { describe, test } from "@std/testing/bdd";
import { extractEdgePop } from "./edge-pop";
describe("extractEdgePop", () => { test("cloudflare colo from cf-ray", () => { const result = extractEdgePop( { "Cf-Ray": "8c9a1b2c3d4e5f6a-FRA" }, "cloudflare", ); expect(result.pop).toBe("FRA"); expect(result.location).toContain("Frankfurt"); });
test("cloudfront pop from x-amz-cf-pop", () => { const result = extractEdgePop({ "X-Amz-Cf-Pop": "FRA56-P5" }, "cloudfront"); expect(result.pop).toBe("FRA56-P5"); expect(result.location).toContain("Frankfurt"); });
test("fastly pop from x-served-by", () => { const result = extractEdgePop( { "X-Served-By": "cache-fra-etou8220141-FRA" }, "fastly", ); expect(result.pop).toBe("FRA"); expect(result.location).toContain("Frankfurt"); });
test("vercel edge from x-vercel-id first segment", () => { const result = extractEdgePop( { "X-Vercel-Id": "fra1::iad1::82mqm-1724415466843-d608bd28fa1c" }, "vercel", ); expect(result.pop).toBe("fra1"); expect(result.location).toContain("Frankfurt"); });
test("vercel pops resolve via the vercel region map (not IATA)", () => { const result = extractEdgePop({ "X-Vercel-Id": "cle1::abc" }, "vercel"); expect(result.pop).toBe("cle1"); expect(result.location).toContain("Cleveland"); });
test("unknown provider -> null", () => { const result = extractEdgePop({ "X-Cache": "HIT" }, null); expect(result.pop).toBeNull(); expect(result.location).toBeNull(); });
test("missing header -> null", () => { const result = extractEdgePop({}, "cloudflare"); expect(result.pop).toBeNull(); });});