@netdata/charts
Version:
Netdata frontend SDK and chart utilities
36 lines (35 loc) • 907 B
JavaScript
;
var _sparklineCanvas = require("./sparklineCanvas");
describe("getSparklinePoints", function () {
it("scales a single-series range into the canvas bounds", function () {
expect((0, _sparklineCanvas.getSparklinePoints)([0, 5, 10], 100, 24)).toEqual([{
x: 4,
y: 20
}, {
x: 50,
y: 12
}, {
x: 96,
y: 4
}]);
});
it("centers constant values", function () {
expect((0, _sparklineCanvas.getSparklinePoints)([5, 5], 100, 24)).toEqual([{
x: 4,
y: 12
}, {
x: 96,
y: 12
}]);
});
it("preserves gaps and rejects an empty numeric series", function () {
expect((0, _sparklineCanvas.getSparklinePoints)([1, null, 3], 100, 20)).toEqual([{
x: 4,
y: 16
}, null, {
x: 96,
y: 4
}]);
expect((0, _sparklineCanvas.getSparklinePoints)([null, NaN], 100, 20)).toEqual([]);
});
});