@netdata/charts
Version:
Netdata frontend SDK and chart utilities
67 lines • 2.38 kB
JavaScript
import React from "react";
import { screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import { renderWithChart } from "@jest/testUtilities";
import ChartContainer from "./chartContainer";
import { jsx as _jsx } from "react/jsx-runtime";
describe("ChartContainer", function () {
it("renders container with data-testid", function () {
renderWithChart(/*#__PURE__*/_jsx(ChartContainer, {
uiName: "default"
}));
expect(screen.getByTestId("chartContent")).toBeInTheDocument();
});
it("passes additional props to Flex container", function () {
renderWithChart(/*#__PURE__*/_jsx(ChartContainer, {
uiName: "default",
className: "custom-class",
"data-custom": "value"
}));
var container = screen.getByTestId("chartContent");
expect(container).toHaveClass("custom-class");
expect(container).toHaveAttribute("data-custom", "value");
});
it("sets correct default styles", function () {
renderWithChart(/*#__PURE__*/_jsx(ChartContainer, {
uiName: "default"
}));
var container = screen.getByTestId("chartContent");
expect(container).toHaveStyle({
overflow: "hidden"
});
expect(container).toHaveAttribute("height", "100%");
expect(container).toHaveAttribute("width", "100%");
});
it("renders with custom dimensions", function () {
renderWithChart(/*#__PURE__*/_jsx(ChartContainer, {
uiName: "default",
width: "200px",
height: "300px"
}));
var container = screen.getByTestId("chartContent");
expect(container).toHaveAttribute("width", "200px");
expect(container).toHaveAttribute("height", "300px");
});
it("renders chart canvas when mounted", function () {
renderWithChart(/*#__PURE__*/_jsx(ChartContainer, {
uiName: "default"
}));
var container = screen.getByTestId("chartContent");
var canvas = container.querySelector("canvas");
expect(canvas).toBeInTheDocument();
});
it("applies flex properties", function () {
renderWithChart(/*#__PURE__*/_jsx(ChartContainer, {
uiName: "default",
alignItems: "center",
justifyContent: "center",
column: true
}));
var container = screen.getByTestId("chartContent");
expect(container).toHaveStyle({
alignItems: "center",
justifyContent: "center",
flexDirection: "column"
});
});
});