@windstream/react-shared-components 0.2.54 → 0.2.55
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.
- package/dist/contentful/index.esm.js +1 -1
- package/dist/contentful/index.esm.js.map +1 -1
- package/dist/contentful/index.js +1 -1
- package/dist/contentful/index.js.map +1 -1
- package/package.json +1 -1
- package/src/contentful/blocks/primary-hero/index.test.tsx +28 -3
- package/src/contentful/blocks/primary-hero/index.tsx +5 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PrimaryHero } from "./index";
|
|
3
3
|
|
|
4
|
-
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
5
5
|
|
|
6
6
|
jest.mock("@shared/components/checklist", () => ({
|
|
7
7
|
Checklist: ({ items }: any) => (
|
|
@@ -14,8 +14,14 @@ jest.mock("@shared/components/checklist", () => ({
|
|
|
14
14
|
}));
|
|
15
15
|
|
|
16
16
|
jest.mock("@shared/components/next-image", () => ({
|
|
17
|
-
NextImage: ({ src, alt, className }: any) => (
|
|
18
|
-
<img
|
|
17
|
+
NextImage: ({ src, alt, className, onClick }: any) => (
|
|
18
|
+
<img
|
|
19
|
+
data-testid="next-image"
|
|
20
|
+
src={src}
|
|
21
|
+
alt={alt}
|
|
22
|
+
className={className}
|
|
23
|
+
onClick={onClick}
|
|
24
|
+
/>
|
|
19
25
|
),
|
|
20
26
|
}));
|
|
21
27
|
|
|
@@ -347,6 +353,25 @@ describe("PrimaryHero", () => {
|
|
|
347
353
|
expect(badges).toHaveLength(2);
|
|
348
354
|
});
|
|
349
355
|
|
|
356
|
+
it("adds cursor class and triggers onImageClick for badge image", () => {
|
|
357
|
+
const onImageClick = jest.fn();
|
|
358
|
+
|
|
359
|
+
render(
|
|
360
|
+
<PrimaryHero
|
|
361
|
+
{...baseProps}
|
|
362
|
+
badgeImage="https://img.test/badge.png"
|
|
363
|
+
onImageClick={onImageClick}
|
|
364
|
+
/>
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
const badges = screen.getAllByAltText("Badge");
|
|
368
|
+
expect(badges).toHaveLength(2);
|
|
369
|
+
badges.forEach((badge) => expect(badge).toHaveClass("cursor-pointer"));
|
|
370
|
+
|
|
371
|
+
fireEvent.click(badges[0]);
|
|
372
|
+
expect(onImageClick).toHaveBeenCalledTimes(1);
|
|
373
|
+
});
|
|
374
|
+
|
|
350
375
|
it("does not render badge image when not provided", () => {
|
|
351
376
|
render(<PrimaryHero {...baseProps} />);
|
|
352
377
|
expect(screen.queryByAltText("Badge")).not.toBeInTheDocument();
|
|
@@ -310,7 +310,11 @@ export const PrimaryHero: React.FC<PrimaryHeroProps> = props => {
|
|
|
310
310
|
<NextImage
|
|
311
311
|
src={badgeImageUrl || ""}
|
|
312
312
|
alt={"Badge"}
|
|
313
|
-
className=
|
|
313
|
+
className={cx(
|
|
314
|
+
"absolute left-5 top-5 aspect-square w-26 object-cover object-center",
|
|
315
|
+
onImageClick && "cursor-pointer"
|
|
316
|
+
)}
|
|
317
|
+
onClick={onImageClick}
|
|
314
318
|
width={104}
|
|
315
319
|
height={104}
|
|
316
320
|
quality={90}
|