import { describe, it, expect, afterEach } from 'vitest'; import { render, cleanup } from "@testing-library/svelte"; import { Icon2fa } from "./src/tabler-icons-svelte"; describe("Svelte Icon component", () => { afterEach(() => cleanup()) it("should render icon component", () => { const { container } = render(Icon2fa); expect(container.getElementsByTagName("svg").length).toBeGreaterThan(0); }); it('should add a class to the element', () => { const { container } = render(Icon2fa, { props: { class: 'test-class', }, }) const svg = container.getElementsByTagName("svg")[0] expect(svg).toHaveClass('test-class') expect(svg).toHaveClass('tabler-icon') expect(svg).toHaveClass('tabler-icon-2fa') }) it('should add a style attribute to the element', () => { const { container } = render(Icon2fa, { props: { style: 'color: red', }, }) const svg = container.getElementsByTagName("svg")[0] expect(svg).toHaveStyle('color: rgb(255, 0, 0)') }) it("should update svg attributes when there are props passed to the component", () => { const { container } = render(Icon2fa, { size: 48, color: "red", strokeWidth: 4, }); const svg = container.getElementsByTagName("svg")[0]; expect(svg.getAttribute("width")).toBe("48"); expect(svg.getAttribute("stroke")).toBe("red"); expect(svg.getAttribute("stroke-width")).toBe("4"); }); it("should match snapshot", () => { const { container } = render(Icon2fa); expect(container.innerHTML).toMatchInlineSnapshot(`