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.6 kB ยท 56 lines
TypeScript
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import { expect } from "@std/expect";import { describe, test } from "@std/testing/bdd";
import { getPayloadConfigFromPayload } from "./chart";
const config = { latency: { label: "Latency" }, ams: { label: "Amsterdam" },};
describe("getPayloadConfigFromPayload", () => { test("returns undefined for a non-object payload", () => { expect( getPayloadConfigFromPayload(config, null, "latency"), ).toBeUndefined(); expect(getPayloadConfigFromPayload(config, "x", "latency")).toBeUndefined(); });
test("uses the key directly when the payload has no string override", () => { expect( getPayloadConfigFromPayload(config, { latency: 12 }, "latency"), ).toEqual({ label: "Latency" }); });
test("redirects through a string value on the payload", () => { expect( getPayloadConfigFromPayload(config, { name: "ams" }, "name"), ).toEqual({ label: "Amsterdam" }); });
test("redirects through a string value on the nested payload", () => { expect( getPayloadConfigFromPayload( config, { payload: { region: "ams" } }, "region", ), ).toEqual({ label: "Amsterdam" }); });
test("prefers the top-level value over the nested one", () => { expect( getPayloadConfigFromPayload( config, { region: "latency", payload: { region: "ams" } }, "region", ), ).toEqual({ label: "Latency" }); });
test("falls back to the key when the redirect is not in the config", () => { expect( getPayloadConfigFromPayload(config, { latency: "fra" }, "latency"), ).toEqual({ label: "Latency" }); });});