import React from "react"; import { render, screen } from "@testing-library/react"; import "@testing-library/jest-dom"; import { CLASSPREFIX as eccgui } from "../../configuration/constants"; import Icon from "../Icon/Icon"; import Button from "./Button"; import { FullExample } from "./Button.stories"; describe("Button", () => { it("should render default button successfully", () => { render(); expect(screen.getByRole("button")).toHaveTextContent(/default button/i); }); it("should have icon at the left followed by text", () => { const { container } = render( , ); expect(screen.getByRole("button").lastChild).toEqual(screen.getByText(/left icon/i)); expect(container.getElementsByClassName(`${eccgui}-icon`).length).toBe(1); }); it("should have icon at the right after the text", () => { const { container } = render( , ); expect(screen.getByRole("button").firstChild).toEqual(screen.getByText(/right icon/i)); expect(container.getElementsByClassName(`${eccgui}-icon`).length).toBe(1); }); it("should render badge markup with correct content when used on an icon button", () => { const { container } = render(