Files
cloudflare__vinext/tests/benchmark-chart-points.test.ts
T
Alexander Lichter dba7d5cd50 feat(benchmarks): reduce repeated chart markers (#2286)
* feat(benchmarks): reduce repeated chart markers

* fix(benchmarks): group markers by displayed value
2026-06-24 10:13:18 +01:00

36 lines
983 B
TypeScript

import { describe, expect, it } from "vitest";
import { visibleMarkerMask } from "../apps/web/app/benchmarks/components/chart-points";
describe("benchmark chart point markers", () => {
it("shows only the boundaries of a repeated plateau", () => {
expect(visibleMarkerMask([5, 5, 5, 5])).toEqual([true, false, false, true]);
});
it("shows every non-repeated value", () => {
expect(visibleMarkerMask([1, 2, 3, 4])).toEqual([true, true, true, true]);
});
it("groups values that have the same displayed value", () => {
const formatValue = (value: number) => value.toFixed(1);
expect(visibleMarkerMask([117.21, 117.22, 117.24, 117.31], formatValue)).toEqual([
true,
false,
true,
true,
]);
});
it("treats missing values as plateau boundaries", () => {
expect(visibleMarkerMask([null, 4, 4, null, 4, 4, 4])).toEqual([
false,
true,
true,
false,
true,
false,
true,
]);
});
});