@windstream/react-shared-components 0.1.93 → 0.1.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/contentful/index.esm.js +2 -2
  2. package/dist/contentful/index.esm.js.map +1 -1
  3. package/dist/contentful/index.js +3 -3
  4. package/dist/contentful/index.js.map +1 -1
  5. package/dist/core.d.ts +2 -2
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.esm.js +1 -1
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.js +3 -3
  10. package/dist/index.js.map +1 -1
  11. package/dist/styles.css +1 -1
  12. package/dist/utils/index.esm.js +1 -1
  13. package/dist/utils/index.js +1 -1
  14. package/package.json +14 -8
  15. package/src/components/accordion/index.test.tsx +270 -0
  16. package/src/components/alert-card/index.test.tsx +152 -0
  17. package/src/components/animation-wrapper/index.test.tsx +424 -0
  18. package/src/components/brand-button/index.test.tsx +292 -0
  19. package/src/components/button/index.test.tsx +91 -0
  20. package/src/components/call-button/index.test.tsx +260 -0
  21. package/src/components/checkbox/index.test.tsx +252 -0
  22. package/src/components/checklist/index.test.tsx +231 -0
  23. package/src/components/checklist/index.tsx +64 -29
  24. package/src/components/checklist/types.ts +7 -1
  25. package/src/components/collapse/index.test.tsx +277 -0
  26. package/src/components/collapse/index.tsx +1 -0
  27. package/src/components/divider/index.test.tsx +53 -0
  28. package/src/components/image/index.test.tsx +174 -0
  29. package/src/components/input/index.test.tsx +348 -0
  30. package/src/components/link/index.test.tsx +199 -0
  31. package/src/components/list/index.test.tsx +166 -0
  32. package/src/components/material-icon/index.test.tsx +130 -0
  33. package/src/components/modal/index.test.tsx +310 -0
  34. package/src/components/next-image/index.test.tsx +406 -0
  35. package/src/components/pagination/index.test.tsx +521 -0
  36. package/src/components/radio-button/index.test.tsx +151 -0
  37. package/src/components/see-more/index.test.tsx +96 -0
  38. package/src/components/select/index.test.tsx +256 -0
  39. package/src/components/select-plan-button/index.test.tsx +173 -0
  40. package/src/components/skeleton/index.test.tsx +74 -0
  41. package/src/components/spinner/index.test.tsx +76 -0
  42. package/src/components/text/index.test.tsx +65 -0
  43. package/src/components/tooltip/index.test.tsx +50 -0
  44. package/src/components/view-cart-button/index.test.tsx +57 -0
  45. package/src/contentful/blocks/accordion/index.test.tsx +218 -0
  46. package/src/contentful/blocks/accordion/index.tsx +3 -1
  47. package/src/contentful/blocks/address-input-banner/index.test.tsx +132 -0
  48. package/src/contentful/blocks/anchored-bottom-banner/index.test.tsx +287 -0
  49. package/src/contentful/blocks/blogs-grid/BlogGrid.stories.tsx +5 -4
  50. package/src/contentful/blocks/blogs-grid/index.test.tsx +355 -0
  51. package/src/contentful/blocks/blogs-grid-base/index.test.tsx +274 -0
  52. package/src/contentful/blocks/breadcrumbs/index.test.tsx +281 -0
  53. package/src/contentful/blocks/button/index.test.tsx +339 -0
  54. package/src/contentful/blocks/callout/index.test.tsx +539 -0
  55. package/src/contentful/blocks/cards/blog-card/index.test.tsx +218 -0
  56. package/src/contentful/blocks/cards/floating-image-card/index.test.tsx +201 -0
  57. package/src/contentful/blocks/cards/full-image-card/index.test.tsx +216 -0
  58. package/src/contentful/blocks/cards/index.test.tsx +39 -0
  59. package/src/contentful/blocks/cards/product-card/index.test.tsx +263 -0
  60. package/src/contentful/blocks/cards/simple-card/index.test.tsx +364 -0
  61. package/src/contentful/blocks/cards/simple-card/index.tsx +1 -1
  62. package/src/contentful/blocks/cards/testimonial-card/index.test.tsx +180 -0
  63. package/src/contentful/blocks/carousel/helper.test.tsx +539 -0
  64. package/src/contentful/blocks/carousel/index.test.tsx +308 -0
  65. package/src/contentful/blocks/carousel/types.test.ts +16 -0
  66. package/src/contentful/blocks/cart-retention-banner/index.test.tsx +409 -0
  67. package/src/contentful/blocks/cart-retention-banner/index.tsx +4 -4
  68. package/src/contentful/blocks/comparison-table/index.test.tsx +114 -0
  69. package/src/contentful/blocks/cookiebanner/index.test.tsx +277 -0
  70. package/src/contentful/blocks/cta-callout/index.test.tsx +244 -0
  71. package/src/contentful/blocks/dynamic-tabs/index.test.tsx +240 -0
  72. package/src/contentful/blocks/email-input-block/index.test.tsx +213 -0
  73. package/src/contentful/blocks/email-input-block/index.tsx +40 -35
  74. package/src/contentful/blocks/find-kinetic/index.test.tsx +269 -0
  75. package/src/contentful/blocks/floating-banner/index.test.tsx +246 -0
  76. package/src/contentful/blocks/footer/index.test.tsx +302 -0
  77. package/src/contentful/blocks/image-promo-bar/helper.test.tsx +61 -0
  78. package/src/contentful/blocks/image-promo-bar/index.test.tsx +467 -0
  79. package/src/contentful/blocks/image-promo-bar/index.tsx +248 -246
  80. package/src/contentful/blocks/image-promo-bar/vimeo-embed.test.tsx +142 -0
  81. package/src/contentful/blocks/image-promo-bar/youtube-embed.test.tsx +104 -0
  82. package/src/contentful/blocks/modal/index.test.tsx +209 -0
  83. package/src/contentful/blocks/navigation/desktop-link-groups.tsx/index.test.tsx +208 -0
  84. package/src/contentful/blocks/navigation/index.test.tsx +924 -0
  85. package/src/contentful/blocks/navigation/mobile-link-groups.tsx/index.test.tsx +131 -0
  86. package/src/contentful/blocks/primary-hero/index.test.tsx +286 -0
  87. package/src/contentful/blocks/primary-hero/index.tsx +7 -4
  88. package/src/contentful/blocks/search-block/index.test.tsx +268 -0
  89. package/src/contentful/blocks/shape-background-wrapper/index.test.tsx +284 -0
  90. package/src/contentful/blocks/text/index.test.tsx +36 -0
  91. package/src/contentful/index.test.ts +45 -0
  92. package/src/global-mocks/contentful/to-document.ts +25 -0
  93. package/src/global-mocks/cookie.ts +48 -0
  94. package/src/global-mocks/cx.ts +37 -0
  95. package/src/global-mocks/index.ts +89 -0
  96. package/src/global-mocks/speed-card-bg.ts +27 -0
  97. package/src/global-mocks/utm.ts +49 -0
  98. package/src/hooks/contentful/use-contentful-rich-text.test.tsx +1758 -0
  99. package/src/hooks/contentful/use-contentful-rich-text.tsx +1 -1
  100. package/src/hooks/contentful/use-processed-check-list.test.tsx +277 -0
  101. package/src/hooks/use-body-scroll-lock.test.ts +134 -0
  102. package/src/hooks/use-carousel-swipe.test.ts +393 -0
  103. package/src/hooks/use-outside-click.test.ts +142 -0
  104. package/src/index.ts +1 -1
  105. package/src/next/index.test.ts +7 -0
  106. package/src/setupTests.ts +17 -11
  107. package/src/utils/contentful/to-document.test.ts +85 -0
  108. package/src/utils/cookie.test.ts +180 -0
  109. package/src/utils/cx.test.ts +90 -0
  110. package/src/utils/index.test.ts +115 -0
  111. package/src/utils/speed-card-bg.test.ts +46 -0
  112. package/src/utils/utm.test.ts +359 -0
@@ -0,0 +1,180 @@
1
+ import React from "react";
2
+ import { TestimonialCard } from "./index";
3
+
4
+ import { render, screen } from "@testing-library/react";
5
+
6
+ jest.mock("@shared/components/material-icon", () => ({
7
+ MaterialIcon: ({ name, className }: any) => (
8
+ <span data-testid="material-icon" className={className}>
9
+ {name}
10
+ </span>
11
+ ),
12
+ }));
13
+
14
+ jest.mock("@shared/components/text", () => ({
15
+ Text: ({ as: Tag = "span", children, className }: any) => (
16
+ <Tag className={className}>{children}</Tag>
17
+ ),
18
+ }));
19
+
20
+ jest.mock("next/image", () => {
21
+ const MockImage = ({ src, alt, className }: any) => (
22
+ <img data-testid="avatar-image" src={src} alt={alt} className={className} />
23
+ );
24
+ return MockImage;
25
+ });
26
+
27
+ jest.mock(
28
+ "clsx",
29
+ () =>
30
+ (...args: any[]) =>
31
+ args.flat().filter(Boolean).join(" ")
32
+ );
33
+
34
+ describe("TestimonialCard", () => {
35
+ const defaultProps = {
36
+ title: "Great Service",
37
+ quote: "This is an amazing product!",
38
+ rating: 4,
39
+ author: "John Doe",
40
+ role: "CEO",
41
+ };
42
+
43
+ describe("Rendering", () => {
44
+ it("renders the figure element", () => {
45
+ const { container } = render(<TestimonialCard {...defaultProps} />);
46
+ expect(container.querySelector("figure")).toBeInTheDocument();
47
+ });
48
+
49
+ it("renders title", () => {
50
+ render(<TestimonialCard {...defaultProps} />);
51
+ expect(screen.getByText("Great Service")).toBeInTheDocument();
52
+ });
53
+
54
+ it("renders quote", () => {
55
+ render(<TestimonialCard {...defaultProps} />);
56
+ expect(
57
+ screen.getByText("This is an amazing product!")
58
+ ).toBeInTheDocument();
59
+ });
60
+
61
+ it("renders author name", () => {
62
+ render(<TestimonialCard {...defaultProps} />);
63
+ expect(screen.getByText("John Doe")).toBeInTheDocument();
64
+ });
65
+
66
+ it("renders author role", () => {
67
+ render(<TestimonialCard {...defaultProps} />);
68
+ expect(screen.getByText("CEO")).toBeInTheDocument();
69
+ });
70
+ });
71
+
72
+ describe("Rating", () => {
73
+ it("renders 5 star icons", () => {
74
+ render(<TestimonialCard {...defaultProps} rating={4} />);
75
+ const icons = screen.getAllByTestId("material-icon");
76
+ expect(icons).toHaveLength(5);
77
+ });
78
+
79
+ it("applies filled class to rated stars", () => {
80
+ render(<TestimonialCard {...defaultProps} rating={3} />);
81
+ const icons = screen.getAllByTestId("material-icon");
82
+ const filledIcons = icons.filter(icon =>
83
+ icon.className.includes("text-text")
84
+ );
85
+ expect(filledIcons.length).toBe(3);
86
+ });
87
+
88
+ it("applies unfilled class to remaining stars", () => {
89
+ render(<TestimonialCard {...defaultProps} rating={3} />);
90
+ const icons = screen.getAllByTestId("material-icon");
91
+ const unfilledIcons = icons.filter(icon =>
92
+ icon.className.includes("text-gray-300")
93
+ );
94
+ expect(unfilledIcons.length).toBe(2);
95
+ });
96
+
97
+ it("does not render rating section when rating is undefined", () => {
98
+ render(<TestimonialCard {...defaultProps} rating={undefined} />);
99
+ expect(screen.queryByTestId("material-icon")).not.toBeInTheDocument();
100
+ });
101
+
102
+ it("renders rating aria-label", () => {
103
+ const { container } = render(
104
+ <TestimonialCard {...defaultProps} rating={4} />
105
+ );
106
+ const ratingDiv = container.querySelector("[aria-label]");
107
+ expect(ratingDiv).toHaveAttribute("aria-label", "Rating: 4 out of 5");
108
+ });
109
+ });
110
+
111
+ describe("Avatar", () => {
112
+ it("renders avatar image when avatarUrl is provided", () => {
113
+ render(<TestimonialCard {...defaultProps} avatarUrl="/avatar.jpg" />);
114
+ expect(screen.getByTestId("avatar-image")).toBeInTheDocument();
115
+ expect(screen.getByTestId("avatar-image")).toHaveAttribute(
116
+ "src",
117
+ "/avatar.jpg"
118
+ );
119
+ });
120
+
121
+ it("renders initials when avatarUrl is not provided", () => {
122
+ render(<TestimonialCard {...defaultProps} />);
123
+ expect(screen.getByText("J")).toBeInTheDocument();
124
+ });
125
+ });
126
+
127
+ describe("Active state", () => {
128
+ it("applies active styles when isActive is true", () => {
129
+ const { container } = render(
130
+ <TestimonialCard {...defaultProps} isActive={true} />
131
+ );
132
+ const figure = container.querySelector("figure");
133
+ expect(figure?.className).toContain("bg-bg-surface-secondary");
134
+ expect(figure?.className).toContain("shadow-drop");
135
+ });
136
+
137
+ it("applies inactive styles when isActive is false", () => {
138
+ const { container } = render(
139
+ <TestimonialCard {...defaultProps} isActive={false} />
140
+ );
141
+ const figure = container.querySelector("figure");
142
+ expect(figure?.className).toContain("opacity-40");
143
+ });
144
+
145
+ it("defaults to inactive", () => {
146
+ const { container } = render(<TestimonialCard {...defaultProps} />);
147
+ const figure = container.querySelector("figure");
148
+ expect(figure?.className).toContain("opacity-40");
149
+ });
150
+ });
151
+
152
+ describe("Custom className", () => {
153
+ it("applies custom className", () => {
154
+ const { container } = render(
155
+ <TestimonialCard {...defaultProps} className="custom-card" />
156
+ );
157
+ const figure = container.querySelector("figure");
158
+ expect(figure?.className).toContain("custom-card");
159
+ });
160
+ });
161
+
162
+ describe("Author section", () => {
163
+ it("does not render author section when author is not provided", () => {
164
+ const { container } = render(
165
+ <TestimonialCard
166
+ title="Test"
167
+ quote="Quote"
168
+ rating={5}
169
+ author={undefined}
170
+ />
171
+ );
172
+ expect(container.querySelector("figcaption")).not.toBeInTheDocument();
173
+ });
174
+
175
+ it("renders figcaption when author is provided", () => {
176
+ const { container } = render(<TestimonialCard {...defaultProps} />);
177
+ expect(container.querySelector("figcaption")).toBeInTheDocument();
178
+ });
179
+ });
180
+ });