test.spec.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import React from "react";
  2. import { render } from "@testing-library/react";
  3. import { IconActivity } from "@tabler/icons-react";
  4. describe("React Icon component", () => {
  5. it("should render an component", () => {
  6. const { container } = render(<IconActivity />);
  7. expect(container.innerHTML).toMatchInlineSnapshot(
  8. `"<svg xmlns=\\"http://www.w3.org/2000/svg\\" width=\\"24\\" height=\\"24\\" viewBox=\\"0 0 24 24\\" fill=\\"none\\" stroke=\\"currentColor\\" stroke-width=\\"2\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" class=\\"tabler-icon tabler-icon-IconActivity\\"><path d=\\"M3 12h4l3 8l4 -16l3 8h4\\"></path></svg>"`
  9. );
  10. });
  11. it("should adjust the size, stroke color and stroke width", () => {
  12. const testId = "icon";
  13. const { container, getByTestId } = render(
  14. <IconActivity
  15. data-testid={testId}
  16. size={48}
  17. stroke="red"
  18. strokeWidth={4}
  19. className={"icon-class"}
  20. />
  21. );
  22. const { attributes } = getByTestId(testId);
  23. expect(attributes.stroke.value).toBe("red");
  24. expect(attributes.width.value).toBe("48");
  25. expect(attributes.height.value).toBe("48");
  26. expect(attributes["stroke-width"].value).toBe("4");
  27. expect(container.innerHTML).toMatchInlineSnapshot(
  28. `"<svg xmlns=\\"http://www.w3.org/2000/svg\\" width=\\"48\\" height=\\"48\\" viewBox=\\"0 0 24 24\\" fill=\\"none\\" stroke=\\"red\\" stroke-width=\\"4\\" stroke-linecap=\\"round\\" stroke-linejoin=\\"round\\" class=\\"icon-class\\" data-testid=\\"icon\\"><path d=\\"M3 12h4l3 8l4 -16l3 8h4\\"></path></svg>"`
  29. );
  30. });
  31. });