UNPKG

@netdata/netdata-ui

Version:

netdata UI kit

44 lines 1.91 kB
import React from "react"; import { renderWithProviders, screen } from "testUtilities"; import PillIcon from "./icon"; describe("PillIcon component", function () { test("should not render component", function () { renderWithProviders(/*#__PURE__*/React.createElement(PillIcon, null)); expect(screen.queryByTestId("pill-icon")).not.toBeInTheDocument(); }); test("should render default component", function () { renderWithProviders(/*#__PURE__*/React.createElement(PillIcon, { icon: "alarm_bell" })); expect(screen.queryByTestId("pill-icon")).toBeInTheDocument(); expect(screen.queryByTestId("pill-icon")).toHaveAttribute("color", "bright"); expect(screen.queryByTestId("pill-icon")).toHaveAttribute("height", "14px"); expect(screen.queryByTestId("pill-icon")).toHaveAttribute("width", "14px"); }); test("should render component with custom test id", function () { var mockedIcon = /*#__PURE__*/React.createElement("div", { "data-testid": "custom-icon" }, "Icon"); renderWithProviders(/*#__PURE__*/React.createElement(PillIcon, { icon: mockedIcon })); expect(screen.queryByTestId("pill-icon")).not.toBeInTheDocument(); expect(screen.queryByTestId("custom-icon")).toBeInTheDocument(); }); test("should render component with custom color", function () { var mockedColor = "primary"; renderWithProviders(/*#__PURE__*/React.createElement(PillIcon, { icon: "alarm_bell", color: mockedColor })); expect(screen.queryByTestId("pill-icon")).toHaveAttribute("color", mockedColor); }); test("should render component with hollowed warning color", function () { renderWithProviders(/*#__PURE__*/React.createElement(PillIcon, { icon: "alarm_bell", hollow: true, flavour: "warning" })); expect(screen.queryByTestId("pill-icon")).toHaveAttribute("color", "warning"); }); });