UNPKG

@netdata/charts

Version:

Netdata frontend SDK and chart utilities

41 lines 1.64 kB
import React from "react"; import { fireEvent, screen } from "@testing-library/react"; import "@testing-library/jest-dom"; import { renderWithChart, makeTestChart } from "@jest/testUtilities"; import Aggregate from "./aggregate"; import { jsx as _jsx } from "react/jsx-runtime"; describe("Aggregate", function () { it("offers percentage aggregation", function () { renderWithChart(/*#__PURE__*/_jsx(Aggregate, {}), { attributes: { aggregationMethod: "avg" } }); fireEvent.click(screen.getByRole("button")); expect(screen.getByText("Average")).toBeInTheDocument(); expect(screen.getByText("Sum")).toBeInTheDocument(); expect(screen.getByText("Percentage")).toBeInTheDocument(); expect(screen.getByText("Minimum")).toBeInTheDocument(); }); it("selects percentage aggregation", function () { var _renderWithChart = renderWithChart(/*#__PURE__*/_jsx(Aggregate, {}), { attributes: { aggregationMethod: "avg" } }), chart = _renderWithChart.chart; fireEvent.click(screen.getByRole("button")); fireEvent.click(screen.getByText("Percentage")); expect(chart.getAttribute("aggregationMethod")).toBe("percentage"); }); it("shows percentage as selected", function () { var _makeTestChart = makeTestChart(), chart = _makeTestChart.chart; chart.updateAttribute("aggregationMethod", "percentage"); renderWithChart(/*#__PURE__*/_jsx(Aggregate, {}), { chart: chart }); expect(screen.getByRole("button")).toHaveAttribute("data-value", "percentage"); expect(screen.getByText("PCT()")).toBeInTheDocument(); }); });