UNPKG

@netdata/netdata-ui

Version:
47 lines (46 loc) 2.4 kB
"use strict"; var _react = _interopRequireDefault(require("react")); var _testUtilities = require("testUtilities"); var _icon = _interopRequireDefault(require("./icon")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } describe("PillIcon component", function () { test("should not render component", function () { (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(_icon["default"], null)); expect(_testUtilities.screen.queryByTestId("pill-icon")).not.toBeInTheDocument(); }); test("should render default component", function () { (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(_icon["default"], { icon: "alarm_bell" })); expect(_testUtilities.screen.queryByTestId("pill-icon")).toBeInTheDocument(); expect(_testUtilities.screen.queryByTestId("pill-icon")).toHaveAttribute("color", "bright"); expect(_testUtilities.screen.queryByTestId("pill-icon")).toHaveAttribute("height", "14px"); expect(_testUtilities.screen.queryByTestId("pill-icon")).toHaveAttribute("width", "14px"); }); test("should render component with custom test id", function () { var mockedIcon = /*#__PURE__*/_react["default"].createElement("div", { "data-testid": "custom-icon" }, "Icon"); (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(_icon["default"], { icon: mockedIcon })); expect(_testUtilities.screen.queryByTestId("pill-icon")).not.toBeInTheDocument(); expect(_testUtilities.screen.queryByTestId("custom-icon")).toBeInTheDocument(); }); test("should render component with custom color", function () { var mockedColor = "primary"; (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(_icon["default"], { icon: "alarm_bell", color: mockedColor })); expect(_testUtilities.screen.queryByTestId("pill-icon")).toHaveAttribute("color", mockedColor); }); test("should render component with hollowed warning color", function () { (0, _testUtilities.renderWithProviders)(/*#__PURE__*/_react["default"].createElement(_icon["default"], { icon: "alarm_bell", hollow: true, flavour: "warning" })); expect(_testUtilities.screen.queryByTestId("pill-icon")).toHaveAttribute("color", "warning"); }); });