@netdata/charts
Version:
Netdata frontend SDK and chart utilities
59 lines • 2.43 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 numberChart from "./index";
import { jsx as _jsx } from "react/jsx-runtime";
describe("numberChart", function () {
it("creates chart instance with required methods", function () {
var _renderWithChart = renderWithChart(/*#__PURE__*/_jsx("div", {}), {
chartType: "number"
}),
chart = _renderWithChart.chart;
var instance = numberChart(chart.sdk, chart);
expect(instance).toHaveProperty("mount");
expect(instance).toHaveProperty("unmount");
expect(instance).toHaveProperty("render");
expect(_typeof(instance.mount)).toBe("function");
expect(_typeof(instance.unmount)).toBe("function");
expect(_typeof(instance.render)).toBe("function");
});
it("mounts without errors", function () {
var _renderWithChart2 = renderWithChart(/*#__PURE__*/_jsx("div", {}), {
chartType: "number"
}),
chart = _renderWithChart2.chart;
var instance = numberChart(chart.sdk, chart);
var element = document.createElement("div");
expect(function () {
return instance.mount(element);
}).not.toThrow();
});
it("unmounts and cleans up resources", function () {
var _renderWithChart3 = renderWithChart(/*#__PURE__*/_jsx("div", {}), {
chartType: "number"
}),
chart = _renderWithChart3.chart;
var instance = numberChart(chart.sdk, chart);
var element = document.createElement("div");
instance.mount(element);
expect(function () {
return instance.unmount();
}).not.toThrow();
});
it("renders without errors when chart is loaded", function () {
var _renderWithChart4 = renderWithChart(/*#__PURE__*/_jsx("div", {}), {
chartType: "number",
attributes: {
loaded: true
}
}),
chart = _renderWithChart4.chart;
var instance = numberChart(chart.sdk, chart);
var element = document.createElement("div");
instance.mount(element);
expect(function () {
return instance.render();
}).not.toThrow();
instance.unmount();
});
});