import React from "react"; import { render } from "@testing-library/react"; import FontIcon from "../FontIcon"; describe("FontIcon", () => { it("should render as an element", () => { const { getByTestId } = render( home ); expect(getByTestId("icon").tagName).toBe("I"); }); it("should render correctly", () => { const { getByTestId, rerender } = render( home ); const icon = getByTestId("icon"); expect(icon).toMatchSnapshot(); rerender(); }); it("should apply the correct classNames", () => { const { getByTestId, rerender } = render(); const icon = getByTestId("icon"); expect(icon.className).toBe("rmd-icon rmd-icon--font material-icons"); expect(icon).toMatchSnapshot(); rerender(); expect(icon.className).toBe( "rmd-icon rmd-icon--font rmd-icon--dense material-icons test-thing" ); expect(icon).toMatchSnapshot(); rerender( ); expect(icon.className).toBe( "rmd-icon rmd-icon--font rmd-icon--dense fa fa-github test-thing" ); expect(icon).toMatchSnapshot(); }); });