test.spec.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { render } from "@testing-library/vue"
  2. import { Icon2fa } from "./src/icons.js"
  3. describe("Vue Icon component", () => {
  4. test("should render icon component", () => {
  5. const { container } = render(Icon2fa)
  6. expect(container.getElementsByTagName("svg").length).toBeGreaterThan(0);
  7. })
  8. test("should update svg attributes when there are props passed to the component", () => {
  9. const { container } = render(Icon2fa, {
  10. props: {
  11. size: 48,
  12. color: "red",
  13. "stroke-width": 4,
  14. },
  15. })
  16. const svg = container.getElementsByTagName("svg")[0]
  17. expect(svg.getAttribute("width")).toBe("48")
  18. expect(svg.getAttribute("stroke")).toBe("red")
  19. expect(svg.getAttribute("stroke-width")).toBe("4")
  20. })
  21. test("should match snapshot", () => {
  22. const { container } = render(Icon2fa);
  23. expect(container.innerHTML).toMatchInlineSnapshot(`
  24. <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-2fa">
  25. <path d="M7 16h-4l3.47 -4.66a2 2 0 1 0 -3.47 -1.54m7 6.2v-8h4m-4 4l3 0m4 4v-6a2 2 0 0 1 4 0v6m-4 -3l4 0"></path>
  26. </svg>
  27. `)
  28. })
  29. })