@netdata/charts
Version:
Netdata frontend SDK and chart utilities
69 lines • 2.51 kB
JavaScript
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
import React from "react";
import { renderWithChart } from "@jest/testUtilities";
import getInitialOptions from "./getInitialOptions";
import { jsx as _jsx } from "react/jsx-runtime";
describe("getInitialOptions", function () {
it("returns valid d3pie configuration object", function () {
var _renderWithChart = renderWithChart(/*#__PURE__*/_jsx("div", {}), {
attributes: {
chartType: "pie"
}
}),
chart = _renderWithChart.chart;
var mockChartUI = {
getElement: function getElement() {
return {
clientWidth: 400,
clientHeight: 300
};
},
chart: chart
};
var options = getInitialOptions(mockChartUI);
expect(options).toHaveProperty("header");
expect(options).toHaveProperty("footer");
expect(options).toHaveProperty("data");
expect(options).toHaveProperty("labels");
expect(options).toHaveProperty("effects");
expect(options).toHaveProperty("tooltips");
expect(options).toHaveProperty("misc");
expect(options).toHaveProperty("callbacks");
expect(options).toHaveProperty("size");
});
it("sets canvas dimensions from element size", function () {
var _renderWithChart2 = renderWithChart(/*#__PURE__*/_jsx("div", {}), {
chartType: "pie"
}),
chart = _renderWithChart2.chart;
var mockChartUI = {
getElement: function getElement() {
return {
clientWidth: 500,
clientHeight: 400
};
},
chart: chart
};
var options = getInitialOptions(mockChartUI);
expect(options.size.canvasWidth).toBe(500);
expect(options.size.canvasHeight).toBe(400);
});
it("includes custom formatter function", function () {
var _renderWithChart3 = renderWithChart(/*#__PURE__*/_jsx("div", {}), {
chartType: "pie"
}),
chart = _renderWithChart3.chart;
var mockChartUI = {
getElement: function getElement() {
return {
clientWidth: 400,
clientHeight: 300
};
},
chart: chart
};
var options = getInitialOptions(mockChartUI);
expect(_typeof(options.labels.formatter)).toBe("function");
});
});