automationDesignPrimitives.test.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { createElement } from "react";
  2. import { renderToStaticMarkup } from "react-dom/server";
  3. import { describe, expect, it } from "vitest";
  4. import {
  5. AutomationChevronDownIcon,
  6. AutomationClockIcon,
  7. AutomationExternalLinkIcon,
  8. AutomationIdleTimeIcon,
  9. AutomationInfoIcon,
  10. AutomationMoreHorizontalIcon,
  11. AutomationRefreshIcon,
  12. AutomationTrashIcon,
  13. } from "@/settings/AutomationDesignPrimitives.js";
  14. describe("AutomationDesignPrimitives icons", () => {
  15. it("uses the Lucide moon on a native 24px viewBox", () => {
  16. const html = renderToStaticMarkup(createElement(AutomationIdleTimeIcon));
  17. expect(html).toContain('viewBox="0 0 24 24"');
  18. expect(html).toContain('stroke="currentColor"');
  19. expect(html).toContain('stroke-width="2"');
  20. });
  21. it("keeps the shared Lucide family displayed at 16px", () => {
  22. const icons = [
  23. AutomationInfoIcon,
  24. AutomationClockIcon,
  25. AutomationMoreHorizontalIcon,
  26. AutomationExternalLinkIcon,
  27. AutomationRefreshIcon,
  28. ];
  29. for (const Icon of icons) {
  30. const html = renderToStaticMarkup(createElement(Icon));
  31. expect(html).toContain('width="16"');
  32. expect(html).toContain('height="16"');
  33. expect(html).toContain('viewBox="0 0 24 24"');
  34. expect(html).toContain('stroke-width="2"');
  35. expect(html).toContain("currentColor");
  36. }
  37. });
  38. it("keeps Lucide chevrons in 20px and 18px containers", () => {
  39. const chevronHtml = renderToStaticMarkup(
  40. createElement(AutomationChevronDownIcon, { size: 14 }),
  41. );
  42. const compactChevronHtml = renderToStaticMarkup(
  43. createElement(AutomationChevronDownIcon, {
  44. size: 14,
  45. containerSize: 18,
  46. }),
  47. );
  48. const trashHtml = renderToStaticMarkup(createElement(AutomationTrashIcon));
  49. expect(chevronHtml).toContain("size-5");
  50. expect(chevronHtml).toContain('viewBox="0 0 24 24"');
  51. expect(chevronHtml).toContain('stroke-width="2"');
  52. expect(compactChevronHtml).toContain("size-4.5");
  53. expect(compactChevronHtml).not.toContain("size-5");
  54. expect(trashHtml).toContain("size-5");
  55. expect(trashHtml).toContain('viewBox="0 0 24 24"');
  56. });
  57. });