UNPKG

@netdata/netdata-ui

Version:

netdata UI kit

47 lines 2.51 kB
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } import React from "react"; import { renderWithProviders, screen } from "testUtilities"; import ConfirmationDialog from "./confirmation-dialog"; var defaultProps = { handleConfirm: jest.fn(), handleDecline: jest.fn(), message: "Text for node deletion", title: "Delete node" }; var setup = function setup(props) { if (props === void 0) { props = defaultProps; } return renderWithProviders(/*#__PURE__*/React.createElement(ConfirmationDialog, props)); }; describe("ConfirmationDialog component", function () { test("should render component", function () { setup(); expect(screen.queryByTestId("confirmationDialog")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-headerContainer")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-header")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-headerIcon")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-headerText")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-headerClose")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-body")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-bodyMessage")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-actions")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-cancelAction")).toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-confirmAction")).toBeInTheDocument(); }); test("should render component without icon", function () { setup(_extends({}, defaultProps, { hideIcon: true })); expect(screen.queryByTestId("confirmationDialog-headerIcon")).not.toBeInTheDocument(); }); test("should render component with custom body message", function () { setup(_extends({}, defaultProps, { message: /*#__PURE__*/React.createElement("div", { "data-testid": "confirmationDialog-customBodyMessage" }, "Text for node deletion") })); expect(screen.queryByTestId("confirmationDialog-bodyMessage")).not.toBeInTheDocument(); expect(screen.queryByTestId("confirmationDialog-customBodyMessage")).toBeInTheDocument(); }); });