@times-components/ts-components 1.146.2-be27d508c972211ad80599875cd69c63bf67d4b1.45 → 1.146.2-e5795a0ef59e2adb61ba52aeb7332fda4405cb7a.4

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 (156) hide show
  1. package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.d.ts +10 -0
  2. package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.js +69 -0
  3. package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.d.ts +12 -0
  4. package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.js +90 -0
  5. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.d.ts +12 -0
  6. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.js +10 -0
  7. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.js +24 -0
  8. package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.js +57 -0
  9. package/dist/components/{carousel-component/__tests__/DefaultPageDot.test.d.ts → opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.d.ts} +1 -0
  10. package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.js +48 -0
  11. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.d.ts +1 -0
  12. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.js +19 -0
  13. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.d.ts +12 -0
  14. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.js +67 -0
  15. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.d.ts +6 -0
  16. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.js +736 -0
  17. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.js +33 -0
  18. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.js +36 -0
  19. package/dist/components/opta/football/opta-match-stats/shared/styles.js +8 -1
  20. package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.js +2 -2
  21. package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.js +1 -1
  22. package/dist/components/opta/football/opta-match-stats/summary/WidgetContainer.js +19 -5
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +2 -2
  25. package/package.json +3 -3
  26. package/rnw.js +1 -1
  27. package/src/components/opta/football/opta-match-stats/commentary/__tests__/__snapshots__/OptaMatchStatsCommentary.test.tsx.snap +1 -1
  28. package/src/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.tsx +108 -0
  29. package/src/components/opta/football/opta-match-stats/matchday-live/MobileWidget.tsx +158 -0
  30. package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.tsx +38 -0
  31. package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.tsx +23 -0
  32. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.tsx +69 -0
  33. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.tsx +61 -0
  34. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/__snapshots__/OptaMatchStatsMatchdayLive.test.tsx.snap +61 -0
  35. package/src/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.tsx +19 -0
  36. package/src/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.tsx +81 -0
  37. package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx +767 -0
  38. package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.tsx +67 -0
  39. package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.tsx +64 -0
  40. package/src/components/opta/football/opta-match-stats/shared/styles.ts +8 -0
  41. package/src/components/opta/football/opta-match-stats/stats-graphs/__tests__/__snapshots__/OptaMatchStatsGraphs.test.tsx.snap +1 -1
  42. package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.tsx +1 -1
  43. package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.tsx +1 -1
  44. package/src/components/opta/football/opta-match-stats/summary/WidgetContainer.tsx +18 -4
  45. package/src/components/opta/football/opta-match-stats/summary/__tests__/__snapshots__/OptaMatchStatsSummary.test.tsx.snap +1 -1
  46. package/src/index.ts +3 -2
  47. package/dist/components/carousel-component/CarouselComponent.stories.js +0 -146
  48. package/dist/components/carousel-component/CarouselItem.d.ts +0 -3
  49. package/dist/components/carousel-component/CarouselItem.js +0 -12
  50. package/dist/components/carousel-component/DefaultNavigationArrow.d.ts +0 -8
  51. package/dist/components/carousel-component/DefaultNavigationArrow.js +0 -6
  52. package/dist/components/carousel-component/DefaultPageDot.d.ts +0 -8
  53. package/dist/components/carousel-component/DefaultPageDot.js +0 -4
  54. package/dist/components/carousel-component/__tests__/CarouselComponent.test.js +0 -163
  55. package/dist/components/carousel-component/__tests__/CarouselItem.test.js +0 -80
  56. package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.js +0 -62
  57. package/dist/components/carousel-component/__tests__/DefaultPageDot.test.js +0 -68
  58. package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.d.ts +0 -1
  59. package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.js +0 -459
  60. package/dist/components/carousel-component/hooks/useCarousel.d.ts +0 -2
  61. package/dist/components/carousel-component/hooks/useCarousel.js +0 -167
  62. package/dist/components/carousel-component/index.d.ts +0 -4
  63. package/dist/components/carousel-component/index.js +0 -20
  64. package/dist/components/carousel-component/styles.d.ts +0 -28
  65. package/dist/components/carousel-component/styles.js +0 -172
  66. package/dist/components/carousel-component/types.d.ts +0 -53
  67. package/dist/components/carousel-component/types.js +0 -2
  68. package/dist/components/trip-cards/SkeletonCard.d.ts +0 -7
  69. package/dist/components/trip-cards/SkeletonCard.js +0 -22
  70. package/dist/components/trip-cards/TripCard.d.ts +0 -3
  71. package/dist/components/trip-cards/TripCard.js +0 -49
  72. package/dist/components/trip-cards/TripCards.stories.d.ts +0 -1
  73. package/dist/components/trip-cards/TripCards.stories.js +0 -159
  74. package/dist/components/trip-cards/TripCardsLayout.d.ts +0 -3
  75. package/dist/components/trip-cards/TripCardsLayout.js +0 -56
  76. package/dist/components/trip-cards/__tests__/SkeletonCard.test.d.ts +0 -1
  77. package/dist/components/trip-cards/__tests__/SkeletonCard.test.js +0 -139
  78. package/dist/components/trip-cards/__tests__/TripCard.test.d.ts +0 -1
  79. package/dist/components/trip-cards/__tests__/TripCard.test.js +0 -95
  80. package/dist/components/trip-cards/__tests__/TripCardsLayout.test.d.ts +0 -1
  81. package/dist/components/trip-cards/__tests__/TripCardsLayout.test.js +0 -314
  82. package/dist/components/trip-cards/__tests__/assets.test.d.ts +0 -1
  83. package/dist/components/trip-cards/__tests__/assets.test.js +0 -165
  84. package/dist/components/trip-cards/__tests__/helpers.test.d.ts +0 -1
  85. package/dist/components/trip-cards/__tests__/helpers.test.js +0 -220
  86. package/dist/components/trip-cards/__tests__/index.test.d.ts +0 -1
  87. package/dist/components/trip-cards/__tests__/index.test.js +0 -478
  88. package/dist/components/trip-cards/__tests__/mockData.test.d.ts +0 -1
  89. package/dist/components/trip-cards/__tests__/mockData.test.js +0 -57
  90. package/dist/components/trip-cards/__tests__/skeletonStyles.test.d.ts +0 -1
  91. package/dist/components/trip-cards/__tests__/skeletonStyles.test.js +0 -194
  92. package/dist/components/trip-cards/assets/BoatIcon.d.ts +0 -1
  93. package/dist/components/trip-cards/assets/BoatIcon.js +0 -4
  94. package/dist/components/trip-cards/assets/CalendarIcon.d.ts +0 -1
  95. package/dist/components/trip-cards/assets/CalendarIcon.js +0 -4
  96. package/dist/components/trip-cards/assets/ChevronRightIcon.d.ts +0 -1
  97. package/dist/components/trip-cards/assets/ChevronRightIcon.js +0 -4
  98. package/dist/components/trip-cards/assets/LocationIcon.d.ts +0 -1
  99. package/dist/components/trip-cards/assets/LocationIcon.js +0 -4
  100. package/dist/components/trip-cards/assets/MoonIcon.d.ts +0 -1
  101. package/dist/components/trip-cards/assets/MoonIcon.js +0 -4
  102. package/dist/components/trip-cards/assets/index.d.ts +0 -6
  103. package/dist/components/trip-cards/assets/index.js +0 -7
  104. package/dist/components/trip-cards/helpers.d.ts +0 -11
  105. package/dist/components/trip-cards/helpers.js +0 -138
  106. package/dist/components/trip-cards/index.d.ts +0 -4
  107. package/dist/components/trip-cards/index.js +0 -68
  108. package/dist/components/trip-cards/mockData.d.ts +0 -3
  109. package/dist/components/trip-cards/mockData.js +0 -317
  110. package/dist/components/trip-cards/skeletonStyles.d.ts +0 -9
  111. package/dist/components/trip-cards/skeletonStyles.js +0 -37
  112. package/dist/components/trip-cards/styles.d.ts +0 -43
  113. package/dist/components/trip-cards/styles.js +0 -404
  114. package/dist/components/trip-cards/types.d.ts +0 -119
  115. package/dist/components/trip-cards/types.js +0 -2
  116. package/src/components/carousel-component/CarouselComponent.stories.tsx +0 -220
  117. package/src/components/carousel-component/CarouselItem.tsx +0 -26
  118. package/src/components/carousel-component/DefaultNavigationArrow.tsx +0 -37
  119. package/src/components/carousel-component/DefaultPageDot.tsx +0 -20
  120. package/src/components/carousel-component/__tests__/CarouselComponent.test.tsx +0 -259
  121. package/src/components/carousel-component/__tests__/CarouselItem.test.tsx +0 -140
  122. package/src/components/carousel-component/__tests__/DefaultNavigationArrow.test.tsx +0 -153
  123. package/src/components/carousel-component/__tests__/DefaultPageDot.test.tsx +0 -105
  124. package/src/components/carousel-component/hooks/__tests__/useCarousel.test.ts +0 -625
  125. package/src/components/carousel-component/hooks/useCarousel.ts +0 -229
  126. package/src/components/carousel-component/index.tsx +0 -92
  127. package/src/components/carousel-component/styles.ts +0 -188
  128. package/src/components/carousel-component/types.ts +0 -62
  129. package/src/components/trip-cards/SkeletonCard.tsx +0 -64
  130. package/src/components/trip-cards/TripCard.tsx +0 -140
  131. package/src/components/trip-cards/TripCards.stories.tsx +0 -224
  132. package/src/components/trip-cards/TripCardsLayout.tsx +0 -145
  133. package/src/components/trip-cards/__tests__/SkeletonCard.test.tsx +0 -169
  134. package/src/components/trip-cards/__tests__/TripCard.test.tsx +0 -120
  135. package/src/components/trip-cards/__tests__/TripCardsLayout.test.tsx +0 -583
  136. package/src/components/trip-cards/__tests__/assets.test.tsx +0 -206
  137. package/src/components/trip-cards/__tests__/helpers.test.ts +0 -272
  138. package/src/components/trip-cards/__tests__/index.test.tsx +0 -550
  139. package/src/components/trip-cards/__tests__/mockData.test.ts +0 -67
  140. package/src/components/trip-cards/__tests__/skeletonStyles.test.tsx +0 -256
  141. package/src/components/trip-cards/assets/BoatIcon.tsx +0 -17
  142. package/src/components/trip-cards/assets/CalendarIcon.tsx +0 -17
  143. package/src/components/trip-cards/assets/ChevronRightIcon.tsx +0 -20
  144. package/src/components/trip-cards/assets/LocationIcon.tsx +0 -17
  145. package/src/components/trip-cards/assets/MoonIcon.tsx +0 -17
  146. package/src/components/trip-cards/assets/index.ts +0 -7
  147. package/src/components/trip-cards/helpers.ts +0 -176
  148. package/src/components/trip-cards/index.tsx +0 -119
  149. package/src/components/trip-cards/mockData.ts +0 -345
  150. package/src/components/trip-cards/skeletonStyles.ts +0 -46
  151. package/src/components/trip-cards/styles.ts +0 -450
  152. package/src/components/trip-cards/types.ts +0 -128
  153. /package/dist/components/{carousel-component/CarouselComponent.stories.d.ts → opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.d.ts} +0 -0
  154. /package/dist/components/{carousel-component/__tests__/CarouselComponent.test.d.ts → opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.d.ts} +0 -0
  155. /package/dist/components/{carousel-component/__tests__/CarouselItem.test.d.ts → opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.d.ts} +0 -0
  156. /package/dist/components/{carousel-component/__tests__/DefaultNavigationArrow.test.d.ts → opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.d.ts} +0 -0
@@ -1,120 +0,0 @@
1
- import React from 'react';
2
- import { render, screen, fireEvent } from '@testing-library/react';
3
- import '@testing-library/jest-dom';
4
- import { TripCard } from '../TripCard';
5
- import { TripCardApiData } from '../types';
6
-
7
- const mockCard: TripCardApiData = {
8
- cruise_id: '2074350',
9
- image: 'https://example.com/image.jpg',
10
- headline: 'Mediterranean from Barcelona',
11
- date: 'Oct 2025 - Oct 2025',
12
- duration: 'Seven Days',
13
- route: 'Barcelona → Marseille',
14
- ship: 'MSC Seaside',
15
- price: '£2000',
16
- logo: 'https://example.com/logo.png',
17
- logo_url: 'https://example.com',
18
- cta_url: 'https://example.com/cruise',
19
- cta_text: 'View Itinerary'
20
- };
21
-
22
- describe('TripCard', () => {
23
- it('renders card with all required data', () => {
24
- render(<TripCard card={mockCard} />);
25
-
26
- expect(
27
- screen.getByText('Mediterranean from Barcelona')
28
- ).toBeInTheDocument();
29
- expect(screen.getByText('Oct 2025 - Oct 2025')).toBeInTheDocument();
30
- expect(screen.getByText('Seven Days')).toBeInTheDocument();
31
- expect(screen.getByText('Barcelona → Marseille')).toBeInTheDocument();
32
- expect(screen.getByText('MSC Seaside')).toBeInTheDocument();
33
- expect(screen.getByText('£2000')).toBeInTheDocument();
34
- expect(screen.getByText('From')).toBeInTheDocument();
35
- expect(screen.getByText('View Itinerary')).toBeInTheDocument();
36
- });
37
-
38
- it('renders image with correct src and alt', () => {
39
- render(<TripCard card={mockCard} />);
40
-
41
- const image = screen.getByAltText('Mediterranean from Barcelona');
42
- expect(image).toHaveAttribute('src', 'https://example.com/image.jpg');
43
- });
44
-
45
- it('renders offer label when provided', () => {
46
- const cardWithOffer = {
47
- ...mockCard,
48
- offer_label: 'Special Offer'
49
- };
50
-
51
- render(<TripCard card={cardWithOffer} />);
52
-
53
- expect(screen.getByText('Special Offer')).toBeInTheDocument();
54
- });
55
-
56
- it('renders gift banner when provided', () => {
57
- const cardWithGift = {
58
- ...mockCard,
59
- gift_banner: 'Free gift with purchase'
60
- };
61
-
62
- render(<TripCard card={cardWithGift} />);
63
-
64
- expect(screen.getByText('Free gift with purchase')).toBeInTheDocument();
65
- });
66
-
67
- it('renders original price when provided', () => {
68
- const cardWithOriginalPrice = {
69
- ...mockCard,
70
- original_price: '£2500'
71
- };
72
-
73
- render(<TripCard card={cardWithOriginalPrice} />);
74
-
75
- expect(screen.getByText('£2500')).toBeInTheDocument();
76
- });
77
-
78
- it('does not render "From" when price is "Enquire now"', () => {
79
- const cardWithEnquire = {
80
- ...mockCard,
81
- price: 'Enquire now'
82
- };
83
-
84
- render(<TripCard card={cardWithEnquire} />);
85
-
86
- expect(screen.queryByText('From')).not.toBeInTheDocument();
87
- expect(screen.getByText('Enquire now')).toBeInTheDocument();
88
- });
89
-
90
- it('renders all CTA links with correct href and target', () => {
91
- render(<TripCard card={mockCard} />);
92
-
93
- const links = screen.getAllByRole('link');
94
- const imageLink = links[0];
95
- const headlineLink = links[1];
96
- const ctaButton = screen.getByText('View Itinerary').closest('a');
97
-
98
- expect(imageLink).toHaveAttribute('href', 'https://example.com/cruise');
99
- expect(imageLink).toHaveAttribute('target', '_blank');
100
- expect(headlineLink).toHaveAttribute('href', 'https://example.com/cruise');
101
- expect(ctaButton).toHaveAttribute('href', 'https://example.com/cruise');
102
- });
103
-
104
- it('renders logo with link when provided', () => {
105
- render(<TripCard card={mockCard} />);
106
- const logoLink = screen.getByRole('link', { name: /partner logo/i });
107
- expect(logoLink).toHaveAttribute('href', 'https://example.com');
108
- const logoImg = screen.getByAltText('Partner logo');
109
- expect(logoImg).toHaveAttribute('src', 'https://example.com/logo.png');
110
- });
111
-
112
- it('shows card image after it loads', () => {
113
- render(<TripCard card={mockCard} />);
114
-
115
- const cardImage = screen.getByAltText('Mediterranean from Barcelona');
116
- expect(cardImage).toHaveStyle({ display: 'none' });
117
- fireEvent.load(cardImage);
118
- expect(cardImage).toHaveStyle({ display: 'block' });
119
- });
120
- });
@@ -1,583 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import '@testing-library/jest-dom';
4
- import { TripCardsLayout } from '../TripCardsLayout';
5
- import { TripCardApiData } from '../types';
6
-
7
- const mockElement = {
8
- class: 'trip-cards',
9
- tripcards: btoa(JSON.stringify([1, 2])),
10
- title: 'Test Cruises',
11
- titleurl: 'https://example.com',
12
- description: 'Test Description'
13
- };
14
-
15
- const MockCard = ({ card }: { card?: TripCardApiData }) => (
16
- <div data-testid="mock-card">
17
- {card ? card.headline || 'Mock Card' : 'Mock Card'}
18
- </div>
19
- );
20
-
21
- // Mock ResizeObserver
22
- global.ResizeObserver = class ResizeObserver {
23
- public observe(): void {
24
- // Mock implementation
25
- }
26
- public unobserve(): void {
27
- // Mock implementation
28
- }
29
- public disconnect(): void {
30
- // Mock implementation
31
- }
32
- };
33
-
34
- describe('TripCardsLayout', () => {
35
- beforeEach(() => {
36
- Element.prototype.scrollTo = jest.fn();
37
-
38
- // Mock matchMedia for each test
39
- Object.defineProperty(window, 'matchMedia', {
40
- writable: true,
41
- configurable: true,
42
- value: jest.fn().mockImplementation(query => ({
43
- matches: false,
44
- media: query,
45
- onchange: null,
46
- addListener: jest.fn(),
47
- removeListener: jest.fn(),
48
- addEventListener: jest.fn(),
49
- removeEventListener: jest.fn(),
50
- dispatchEvent: jest.fn()
51
- }))
52
- });
53
- });
54
-
55
- describe('Rendering', () => {
56
- it('renders with title and description', () => {
57
- const items = [
58
- { id: '1', data: undefined },
59
- { id: '2', data: undefined }
60
- ];
61
-
62
- render(
63
- <TripCardsLayout
64
- element={mockElement}
65
- items={items}
66
- CardComponent={MockCard}
67
- itemsPerPage={2}
68
- />
69
- );
70
-
71
- expect(screen.getByText('Test Cruises')).toBeInTheDocument();
72
- expect(screen.getByText('Test Description')).toBeInTheDocument();
73
- });
74
-
75
- it('renders empty title when not provided', () => {
76
- const elementWithoutTitle = {
77
- ...mockElement,
78
- title: undefined
79
- };
80
-
81
- const items = [{ id: '1', data: undefined }];
82
-
83
- const { container } = render(
84
- <TripCardsLayout
85
- element={elementWithoutTitle}
86
- items={items}
87
- CardComponent={MockCard}
88
- itemsPerPage={2}
89
- />
90
- );
91
-
92
- const title = container.querySelector('h2');
93
- expect(title).toBeInTheDocument();
94
- expect(title).toBeEmptyDOMElement();
95
- });
96
-
97
- it('renders empty description when not provided', () => {
98
- const elementWithoutDesc = {
99
- ...mockElement,
100
- description: undefined
101
- };
102
-
103
- const items = [{ id: '1', data: undefined }];
104
-
105
- const { container } = render(
106
- <TripCardsLayout
107
- element={elementWithoutDesc}
108
- items={items}
109
- CardComponent={MockCard}
110
- itemsPerPage={2}
111
- />
112
- );
113
-
114
- const description = container.querySelector('p');
115
- expect(description).toBeInTheDocument();
116
- expect(description).toBeEmptyDOMElement();
117
- });
118
-
119
- it('renders title link when provided', () => {
120
- const items = [{ id: '1', data: undefined }];
121
-
122
- render(
123
- <TripCardsLayout
124
- element={mockElement}
125
- items={items}
126
- CardComponent={MockCard}
127
- itemsPerPage={2}
128
- />
129
- );
130
-
131
- const link = screen.getByTestId('trip-cards-title-link');
132
- expect(link).toHaveAttribute('href', 'https://example.com');
133
- expect(link).toHaveAttribute('target', '_blank');
134
- expect(link).toHaveAttribute('rel', 'noopener noreferrer');
135
- });
136
-
137
- it('renders two links when titleurl is provided', () => {
138
- const items = [{ id: '1', data: undefined }];
139
-
140
- render(
141
- <TripCardsLayout
142
- element={mockElement}
143
- items={items}
144
- CardComponent={MockCard}
145
- itemsPerPage={2}
146
- />
147
- );
148
-
149
- const links = screen.getAllByRole('link');
150
- expect(links).toHaveLength(2);
151
-
152
- const titleLink = screen.getByTestId('trip-cards-title-link');
153
- const iconLink = screen.getByTestId('title-link');
154
-
155
- expect(titleLink).toHaveAttribute('href', 'https://example.com');
156
- expect(iconLink).toHaveAttribute('href', 'https://example.com');
157
- });
158
-
159
- it('does not render title link when not provided', () => {
160
- const elementWithoutLink = {
161
- ...mockElement,
162
- titleurl: undefined
163
- };
164
-
165
- const items = [{ id: '1', data: undefined }];
166
-
167
- render(
168
- <TripCardsLayout
169
- element={elementWithoutLink}
170
- items={items}
171
- CardComponent={MockCard}
172
- itemsPerPage={2}
173
- />
174
- );
175
-
176
- const links = screen.queryAllByRole('link');
177
- expect(links.length).toBe(0);
178
- });
179
-
180
- it('renders ChevronRightIcon in title link', () => {
181
- const items = [{ id: '1', data: undefined }];
182
-
183
- const { container } = render(
184
- <TripCardsLayout
185
- element={mockElement}
186
- items={items}
187
- CardComponent={MockCard}
188
- itemsPerPage={2}
189
- />
190
- );
191
-
192
- const svg = container.querySelector('svg');
193
- expect(svg).toBeInTheDocument();
194
- });
195
- });
196
-
197
- describe('Static Grid Layout', () => {
198
- it('renders static grid for exactly 2 items', () => {
199
- const items = [
200
- { id: '1', data: undefined },
201
- { id: '2', data: undefined }
202
- ];
203
-
204
- render(
205
- <TripCardsLayout
206
- element={mockElement}
207
- items={items}
208
- CardComponent={MockCard}
209
- itemsPerPage={2}
210
- />
211
- );
212
-
213
- const staticGrid = screen.getByTestId('static-cards-grid');
214
- expect(staticGrid).toBeInTheDocument();
215
- });
216
-
217
- it('renders correct number of cards in static grid', () => {
218
- const items = [
219
- { id: '1', data: undefined },
220
- { id: '2', data: undefined }
221
- ];
222
-
223
- render(
224
- <TripCardsLayout
225
- element={mockElement}
226
- items={items}
227
- CardComponent={MockCard}
228
- itemsPerPage={2}
229
- />
230
- );
231
-
232
- const cards = screen.getAllByTestId('mock-card');
233
- expect(cards.length).toBe(2);
234
- });
235
-
236
- it('passes correct props to CardComponent in static grid', () => {
237
- const mockData: TripCardApiData = {
238
- cruise_id: '1',
239
- image: 'test.jpg',
240
- headline: 'Test Cruise',
241
- date: 'Jan 2024',
242
- duration: '7 nights',
243
- route: 'Test Route',
244
- ship: 'Test Ship',
245
- price: '£1000',
246
- logo: 'logo.png',
247
- logo_url: 'https://example.com',
248
- cta_url: 'https://example.com',
249
- cta_text: 'View'
250
- };
251
-
252
- const items = [{ id: '1', data: mockData }, { id: '2', data: undefined }];
253
-
254
- render(
255
- <TripCardsLayout
256
- element={mockElement}
257
- items={items}
258
- CardComponent={MockCard}
259
- itemsPerPage={2}
260
- />
261
- );
262
-
263
- expect(screen.getByText('Test Cruise')).toBeInTheDocument();
264
- });
265
- });
266
-
267
- describe('Carousel Layout', () => {
268
- it('renders carousel for more than 2 items', () => {
269
- const items = [
270
- { id: '1', data: undefined },
271
- { id: '2', data: undefined },
272
- { id: '3', data: undefined }
273
- ];
274
-
275
- render(
276
- <TripCardsLayout
277
- element={mockElement}
278
- items={items}
279
- CardComponent={MockCard}
280
- itemsPerPage={2}
281
- />
282
- );
283
-
284
- const cards = screen.getAllByTestId('mock-card');
285
- expect(cards.length).toBe(3);
286
- });
287
-
288
- it('renders navigation arrows in carousel', () => {
289
- const items = [
290
- { id: '1', data: undefined },
291
- { id: '2', data: undefined },
292
- { id: '3', data: undefined }
293
- ];
294
-
295
- render(
296
- <TripCardsLayout
297
- element={mockElement}
298
- items={items}
299
- CardComponent={MockCard}
300
- itemsPerPage={2}
301
- />
302
- );
303
-
304
- expect(screen.getByLabelText('Previous items')).toBeInTheDocument();
305
- expect(screen.getByLabelText('Next items')).toBeInTheDocument();
306
- });
307
-
308
- it('renders page dots in carousel', () => {
309
- const items = [
310
- { id: '1', data: undefined },
311
- { id: '2', data: undefined },
312
- { id: '3', data: undefined },
313
- { id: '4', data: undefined }
314
- ];
315
-
316
- render(
317
- <TripCardsLayout
318
- element={mockElement}
319
- items={items}
320
- CardComponent={MockCard}
321
- itemsPerPage={2}
322
- />
323
- );
324
-
325
- expect(screen.getByLabelText('Previous items')).toBeInTheDocument();
326
- expect(screen.getByLabelText('Next items')).toBeInTheDocument();
327
-
328
- // With 4 items and 2 per page, we have 2 pages, so we should have 2 dot buttons
329
- const pageDots = screen.getAllByLabelText(/Go to page/i);
330
- expect(pageDots.length).toBe(2);
331
- });
332
-
333
- it('renders carousel for 1 item', () => {
334
- const items = [{ id: '1', data: undefined }];
335
-
336
- render(
337
- <TripCardsLayout
338
- element={mockElement}
339
- items={items}
340
- CardComponent={MockCard}
341
- itemsPerPage={2}
342
- />
343
- );
344
-
345
- const cards = screen.getAllByTestId('mock-card');
346
- expect(cards.length).toBe(1);
347
- });
348
-
349
- it('wraps cards in CarouselItem with correct widthConfig', () => {
350
- const items = [
351
- { id: '1', data: undefined },
352
- { id: '2', data: undefined },
353
- { id: '3', data: undefined }
354
- ];
355
-
356
- render(
357
- <TripCardsLayout
358
- element={mockElement}
359
- items={items}
360
- CardComponent={MockCard}
361
- itemsPerPage={2}
362
- />
363
- );
364
-
365
- // Verify carousel is rendering by checking for cards
366
- const cards = screen.getAllByTestId('mock-card');
367
- expect(cards.length).toBe(3);
368
- });
369
- });
370
-
371
- describe('Card Rendering', () => {
372
- it('renders each item with unique key', () => {
373
- const items = [
374
- { id: 'card-1', data: undefined },
375
- { id: 'card-2', data: undefined }
376
- ];
377
-
378
- render(
379
- <TripCardsLayout
380
- element={mockElement}
381
- items={items}
382
- CardComponent={MockCard}
383
- itemsPerPage={2}
384
- />
385
- );
386
-
387
- const cards = screen.getAllByTestId('mock-card');
388
- expect(cards.length).toBe(2);
389
- });
390
-
391
- it('passes data to CardComponent', () => {
392
- const mockData: TripCardApiData = {
393
- cruise_id: '123',
394
- image: 'image.jpg',
395
- headline: 'Specific Cruise',
396
- date: 'Feb 2024',
397
- duration: '10 nights',
398
- route: 'Route A',
399
- ship: 'Ship X',
400
- price: '£2000',
401
- logo: 'logo.png',
402
- logo_url: 'https://example.com',
403
- cta_url: 'https://example.com',
404
- cta_text: 'Book'
405
- };
406
-
407
- const items = [
408
- { id: '1', data: mockData },
409
- { id: '2', data: undefined },
410
- { id: '3', data: undefined }
411
- ];
412
-
413
- render(
414
- <TripCardsLayout
415
- element={mockElement}
416
- items={items}
417
- CardComponent={MockCard}
418
- itemsPerPage={2}
419
- />
420
- );
421
-
422
- expect(screen.getByText('Specific Cruise')).toBeInTheDocument();
423
- });
424
-
425
- it('handles empty items array', () => {
426
- const { container } = render(
427
- <TripCardsLayout
428
- element={mockElement}
429
- items={[]}
430
- CardComponent={MockCard}
431
- itemsPerPage={2}
432
- />
433
- );
434
-
435
- expect(container.firstChild).toBeInTheDocument();
436
- const cards = screen.queryAllByTestId('mock-card');
437
- expect(cards.length).toBe(0);
438
- });
439
- });
440
-
441
- describe('Container Structure', () => {
442
- it('renders main container', () => {
443
- const items = [{ id: '1', data: undefined }];
444
-
445
- render(
446
- <TripCardsLayout
447
- element={mockElement}
448
- items={items}
449
- CardComponent={MockCard}
450
- itemsPerPage={2}
451
- />
452
- );
453
-
454
- const mainContainer = screen.getByTestId('trip-cards-container');
455
- expect(mainContainer).toBeInTheDocument();
456
- });
457
-
458
- it('renders title section', () => {
459
- const items = [{ id: '1', data: undefined }];
460
-
461
- render(
462
- <TripCardsLayout
463
- element={mockElement}
464
- items={items}
465
- CardComponent={MockCard}
466
- itemsPerPage={2}
467
- />
468
- );
469
-
470
- const titleSection = screen.getByTestId('title-section');
471
- expect(titleSection).toBeInTheDocument();
472
- });
473
-
474
- it('renders title bar with content', () => {
475
- const items = [{ id: '1', data: undefined }];
476
-
477
- render(
478
- <TripCardsLayout
479
- element={mockElement}
480
- items={items}
481
- CardComponent={MockCard}
482
- itemsPerPage={2}
483
- />
484
- );
485
-
486
- const titleBar = screen.getByTestId('title-bar');
487
- const titleContent = screen.getByTestId('title-content');
488
-
489
- expect(titleBar).toBeInTheDocument();
490
- expect(titleContent).toBeInTheDocument();
491
- });
492
- });
493
-
494
- describe('ItemsPerPage', () => {
495
- it('respects itemsPerPage prop', () => {
496
- const items = Array.from({ length: 6 }, (_, i) => ({
497
- id: `${i}`,
498
- data: undefined
499
- }));
500
-
501
- render(
502
- <TripCardsLayout
503
- element={mockElement}
504
- items={items}
505
- CardComponent={MockCard}
506
- itemsPerPage={3}
507
- />
508
- );
509
-
510
- const cards = screen.getAllByTestId('mock-card');
511
- expect(cards.length).toBe(6);
512
- });
513
-
514
- it('handles itemsPerPage of 1', () => {
515
- const items = [
516
- { id: '1', data: undefined },
517
- { id: '2', data: undefined }
518
- ];
519
-
520
- render(
521
- <TripCardsLayout
522
- element={mockElement}
523
- items={items}
524
- CardComponent={MockCard}
525
- itemsPerPage={1}
526
- />
527
- );
528
-
529
- const cards = screen.getAllByTestId('mock-card');
530
- expect(cards.length).toBe(2);
531
- });
532
- });
533
-
534
- describe('Edge Cases', () => {
535
- it('handles large number of items', () => {
536
- const items = Array.from({ length: 50 }, (_, i) => ({
537
- id: `${i}`,
538
- data: undefined
539
- }));
540
-
541
- render(
542
- <TripCardsLayout
543
- element={mockElement}
544
- items={items}
545
- CardComponent={MockCard}
546
- itemsPerPage={2}
547
- />
548
- );
549
-
550
- const cards = screen.getAllByTestId('mock-card');
551
- expect(cards.length).toBe(50);
552
- });
553
-
554
- it('handles empty title and description', () => {
555
- const emptyElement = {
556
- ...mockElement,
557
- title: '',
558
- description: ''
559
- };
560
-
561
- const items = [{ id: '1', data: undefined }];
562
-
563
- const { container } = render(
564
- <TripCardsLayout
565
- element={emptyElement}
566
- items={items}
567
- CardComponent={MockCard}
568
- itemsPerPage={2}
569
- />
570
- );
571
-
572
- const title = container.querySelector('h2');
573
- const description = container.querySelector('p');
574
-
575
- expect(title).toBeInTheDocument();
576
- expect(description).toBeInTheDocument();
577
- if (title && description) {
578
- expect(title.textContent).toBe('');
579
- expect(description.textContent).toBe('');
580
- }
581
- });
582
- });
583
- });