import React, { FC } from "react";
import cn from "classnames";
import { render } from "@testing-library/react";
import IconRotator from "../IconRotator";
import FontIcon from "../FontIcon";
import SVGIcon from "../SVGIcon";
const Icon: FC<{ className?: string }> = ({ className }) => (
);
describe("IconRotator", () => {
it("should default to cloning the icon rotator class names into the child element", () => {
const { container, getByTestId, rerender } = render(
);
const icon = getByTestId("icon");
expect(icon.className).toBe(
"custom-icon rmd-icon-rotator rmd-icon-rotator--animate"
);
expect(container).toMatchSnapshot();
rerender(
);
expect(icon.className).toBe(
"custom-icon rmd-icon-rotator rmd-icon-rotator--animate rmd-icon-rotator--rotated"
);
expect(container).toMatchSnapshot();
});
it("should work automatically with the FontIcon component", () => {
const { container, rerender } = render(
home
);
expect(container).toMatchSnapshot();
rerender(
home
);
expect(container).toMatchSnapshot();
});
it("should work automatically with the SVGIcon component", () => {
const { container, rerender } = render(
);
expect(container).toMatchSnapshot();
rerender(
);
expect(container).toMatchSnapshot();
});
it("should wrapp the children with a span if the forceIconWrap prop is enabled", () => {
const { container, rerender } = render(
);
expect(container).toMatchSnapshot();
rerender(
);
expect(container).toMatchSnapshot();
rerender(
home
);
expect(container).toMatchSnapshot();
rerender(
home
);
expect(container).toMatchSnapshot();
rerender(
);
expect(container).toMatchSnapshot();
rerender(
);
expect(container).toMatchSnapshot();
});
});