UNPKG

@netdata/charts

Version:

Netdata frontend SDK and chart utilities

67 lines 2.58 kB
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 easyPieChart from "./index"; import { jsx as _jsx } from "react/jsx-runtime"; describe("easyPieChart", function () { it("creates chart instance with required methods", function () { var _renderWithChart = renderWithChart(/*#__PURE__*/_jsx("div", {}), { chartType: "easyPie" }), chart = _renderWithChart.chart; var instance = easyPieChart(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: "easyPie" }), chart = _renderWithChart2.chart; var instance = easyPieChart(chart.sdk, chart); var element = document.createElement("div"); expect(function () { return instance.mount(element); }).not.toThrow(); }); it("unmounts without errors", function () { var _renderWithChart3 = renderWithChart(/*#__PURE__*/_jsx("div", {}), { chartType: "easyPie" }), chart = _renderWithChart3.chart; var instance = easyPieChart(chart.sdk, chart); var element = document.createElement("div"); instance.mount(element); expect(function () { return instance.unmount(); }).not.toThrow(); }); it("renders without errors when loaded", function () { var _renderWithChart4 = renderWithChart(/*#__PURE__*/_jsx("div", {}), { chartType: "easyPie", attributes: { loaded: true } }), chart = _renderWithChart4.chart; chart.getPayload = function () { return { data: [[1, 50, 30]] }; }; chart.getClosestRow = function () { return 0; }; var instance = easyPieChart(chart.sdk, chart); var element = document.createElement("div"); instance.mount(element); expect(function () { return instance.render(); }).not.toThrow(); instance.unmount(); }); });