mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-10-20 08:31:56 +00:00
Port the qualified web preview at c41e6fa8940fba929704bc2f9a94f119fef4a4ca onto
org dev b4d498e697. Preserve upstream changes and
branch policies; keep the independent private Collector service separate.
Preview-Version: 2.2.1-n30nex.1
Preview-Revision: c41e6fa8940fba929704bc2f9a94f119fef4a4ca
16 lines
837 B
TypeScript
16 lines
837 B
TypeScript
import { expect, it } from "vitest";
|
|
import { render } from "@testing-library/react";
|
|
import { StatCard } from "../../../src/features/stats/cards";
|
|
|
|
it("marks the peak hour on a sparkline when asked", () => {
|
|
const { container } = render(<StatCard label="Busiest" value="9" accent="red" spark={[1, 9, null, 4]} markPeak />);
|
|
const dot = container.querySelector("[data-peak]")!;
|
|
expect(Number(dot.getAttribute("x1"))).toBeCloseTo(40.6667,3);
|
|
});
|
|
|
|
it("draws a presence strip with one bar per run of reporting hours", () => {
|
|
const { container } = render(<StatCard label="Active hours" value="3/5" accent="red" presence={[true, true, false, true, false]} />);
|
|
const bars = [...container.querySelectorAll("rect")];
|
|
expect(bars.map((b) => [b.getAttribute("x"), b.getAttribute("width")])).toEqual([["0", "48"], ["72", "24"]]);
|
|
});
|