master @ 28 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ import { describe, expect, it } from "vitest"; │
│ import { buildSparkline } from "./Sparkline"; │
│ │
│ describe("buildSparkline", () => { │
│ it("emits one glyph per value", () => { │
│ expect([...buildSparkline([1, 2, 3])]).toHaveLength(3); │
│ }); │
│ │
│ it("maps min to the lowest block and max to the highest", () => { │
│ const s = [...buildSparkline([0, 100])]; │
│ expect(s[0]).toBe("▁"); │
│ expect(s[1]).toBe("█"); │
│ }); │
│ │
│ it("renders a flat series at mid height", () => { │
│ expect(buildSparkline([5, 5, 5])).toBe("▄▄▄"); │
│ }); │
│ │
│ it("bucket-averages long series down to width", () => { │
│ const s = buildSparkline(Array.from({ length: 100 }, (_, i) => i), 10); │
│ expect([...s]).toHaveLength(10); │
│ }); │
│ │
│ it("handles empty input", () => { │
│ expect(buildSparkline([])).toBe(""); │
│ }); │
│ }); │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ import { describe, expect, it } from "vitest │
│ "; │
│ import { buildSparkline } from "./Sparkline" │
│ ; │
│ │
│ describe("buildSparkline", () => { │
│ it("emits one glyph per value", () => { │
│ expect([...buildSparkline([1, 2, 3])]).t │
│ oHaveLength(3); │
│ }); │
│ │
│ it("maps min to the lowest block and max t │
│ o the highest", () => { │
│ const s = [...buildSparkline([0, 100])]; │
│ expect(s[0]).toBe("▁"); │
│ expect(s[1]).toBe("█"); │
│ }); │
│ │
│ it("renders a flat series at mid height", │
│ () => { │
│ expect(buildSparkline([5, 5, 5])).toBe(" │
│ ▄▄▄"); │
│ }); │
│ │
│ it("bucket-averages long series down to wi │
│ dth", () => { │
│ const s = buildSparkline(Array.from({ le │
│ ngth: 100 }, (_, i) => i), 10); │
│ expect([...s]).toHaveLength(10); │
│ }); │
│ │
│ it("handles empty input", () => { │
│ expect(buildSparkline([])).toBe(""); │
│ }); │
│ }); │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET