feat(charting): unify configurable time windows
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
chartRangesThrough,
|
||||
PROMETHEUS_WINDOW_VALUES,
|
||||
rangeSecondsFromWindow,
|
||||
} from "../chartRanges";
|
||||
|
||||
describe("chart ranges", () => {
|
||||
it("maps every persisted Prometheus window to its display duration", () => {
|
||||
expect(PROMETHEUS_WINDOW_VALUES).toEqual([
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"3h",
|
||||
"6h",
|
||||
"12h",
|
||||
"24h",
|
||||
"2d",
|
||||
"7d",
|
||||
"14d",
|
||||
"30d",
|
||||
]);
|
||||
expect(PROMETHEUS_WINDOW_VALUES.map(rangeSecondsFromWindow)).toEqual([
|
||||
300, 900, 1800, 3600, 10800, 21600, 43200, 86400, 172800, 604800, 1209600,
|
||||
2592000,
|
||||
]);
|
||||
});
|
||||
|
||||
it("offers all values after every finite range through the available history", () => {
|
||||
expect(chartRangesThrough(86_400).at(-1)).toEqual({
|
||||
value: "all",
|
||||
label: "All values",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user