Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
12345678910111213141516171819202122232425import { describe, expect, it } from "vitest";import { summarize } from "#lib/status.ts";
const beats = (...latest: number[]) => Object.fromEntries(latest.map((status, i) => [String(i), [{ status: 1 }, { status }]]));
describe("summarize", () => { it.each([ ["up", beats(1, 1)], ["degraded", beats(1, 0)], ["degraded", beats(1, 2)], ["down", beats(0, 0)], ["maintenance", beats(1, 3)], ["degraded", beats(0, 3)], ["unknown", {}], ["unknown", { "1": [] }] ])("reads %s", (expected, heartbeats) => { expect(summarize(heartbeats)).toBe(expected); });
it("goes by each monitor's latest beat", () => { expect(summarize({ "1": [{ status: 0 }, { status: 1 }] })).toBe("up"); });});