mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-10-19 17:30:05 +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
22 lines
1.2 KiB
TypeScript
22 lines
1.2 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { render } from "@testing-library/react";
|
|
import { Sparkline } from "../../src/components/Sparkline";
|
|
|
|
describe("sparkline evidence", () => {
|
|
it("draws isolated measured zeros and dashed bridges, without changing the input", () => {
|
|
const values = [null, 0, null, 4, 5, null];
|
|
const { container } = render(<Sparkline values={values} color="cyan" />);
|
|
expect(container.querySelectorAll("[data-gap]")).toHaveLength(1);
|
|
expect(container.querySelector("[data-gap]")).toHaveAttribute("stroke-dasharray", "3 3");
|
|
expect(container.querySelectorAll("[data-sample]")).toHaveLength(1);
|
|
expect(values).toEqual([null, 0, null, 4, 5, null]);
|
|
});
|
|
it("marks a long time gap and a single reading, without extrapolating measured points", () => {
|
|
const { container, rerender } = render(<Sparkline values={[1, 2, 3]} times={[0, 1, 100]} gapMs={10} color="green" />);
|
|
expect(container.querySelectorAll("[data-gap]")).toHaveLength(1);
|
|
rerender(<Sparkline values={[0]} color="green" />);
|
|
expect(container.querySelectorAll("[data-sample]")).toHaveLength(1);
|
|
expect(container.querySelectorAll("[data-gap]")).toHaveLength(0);
|
|
});
|
|
});
|