@times-components/ts-components 1.145.1-b32ea924749bafdf12e3e8515023538fa20e7808.3 → 1.145.1-cfea81c4084e6f91221ea00fec9fc730d5b933cb.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 (136) hide show
  1. package/dist/components/carousel-component/CarouselComponent.stories.js +146 -0
  2. package/dist/components/carousel-component/CarouselItem.d.ts +3 -0
  3. package/dist/components/carousel-component/CarouselItem.js +11 -0
  4. package/dist/components/carousel-component/DefaultNavigationArrow.d.ts +8 -0
  5. package/dist/components/carousel-component/DefaultNavigationArrow.js +6 -0
  6. package/dist/components/carousel-component/DefaultPageDot.d.ts +8 -0
  7. package/dist/components/carousel-component/DefaultPageDot.js +4 -0
  8. package/dist/components/carousel-component/__tests__/CarouselComponent.test.d.ts +1 -0
  9. package/dist/components/carousel-component/__tests__/CarouselComponent.test.js +163 -0
  10. package/dist/components/carousel-component/__tests__/CarouselItem.test.d.ts +1 -0
  11. package/dist/components/carousel-component/__tests__/CarouselItem.test.js +80 -0
  12. package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.d.ts +1 -0
  13. package/dist/components/carousel-component/__tests__/DefaultNavigationArrow.test.js +62 -0
  14. package/dist/components/carousel-component/__tests__/DefaultPageDot.test.d.ts +1 -0
  15. package/dist/components/carousel-component/__tests__/DefaultPageDot.test.js +68 -0
  16. package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.d.ts +1 -0
  17. package/dist/components/carousel-component/hooks/__tests__/useCarousel.test.js +314 -0
  18. package/dist/components/carousel-component/hooks/useCarousel.d.ts +2 -0
  19. package/dist/components/carousel-component/hooks/useCarousel.js +140 -0
  20. package/dist/components/carousel-component/index.d.ts +4 -0
  21. package/dist/components/carousel-component/index.js +20 -0
  22. package/dist/components/carousel-component/styles.d.ts +30 -0
  23. package/dist/components/carousel-component/styles.js +120 -0
  24. package/dist/components/carousel-component/types.d.ts +46 -0
  25. package/dist/components/carousel-component/types.js +2 -0
  26. package/dist/components/opta/cricket/scorecard/OptaCricketScorecard.js +2 -10
  27. package/dist/components/opta/cricket/scorecard/__tests__/OptaCricketScorecard.test.js +17 -94
  28. package/dist/components/opta/football/summary/OptaFootballSummary.js +2 -10
  29. package/dist/components/opta/football/summary/__tests__/OptaFootballSummary.test.js +18 -95
  30. package/dist/components/opta/rugby/summary/OptaRugbySummary.js +2 -10
  31. package/dist/components/opta/rugby/summary/__tests__/OptaRugbySummary.test.js +17 -94
  32. package/dist/components/trip-cards/SkeletonCard.d.ts +2 -0
  33. package/dist/components/trip-cards/SkeletonCard.js +21 -0
  34. package/dist/components/trip-cards/TripCard.d.ts +3 -0
  35. package/dist/components/trip-cards/TripCard.js +47 -0
  36. package/dist/components/trip-cards/TripCards.stories.d.ts +1 -0
  37. package/dist/components/trip-cards/TripCards.stories.js +40 -0
  38. package/dist/components/trip-cards/TripCardsLayout.d.ts +3 -0
  39. package/dist/components/trip-cards/TripCardsLayout.js +26 -0
  40. package/dist/components/trip-cards/__tests__/SkeletonCard.test.d.ts +1 -0
  41. package/dist/components/trip-cards/__tests__/SkeletonCard.test.js +139 -0
  42. package/dist/components/trip-cards/__tests__/TripCard.test.d.ts +1 -0
  43. package/dist/components/trip-cards/__tests__/TripCard.test.js +95 -0
  44. package/dist/components/trip-cards/__tests__/TripCardsLayout.test.d.ts +1 -0
  45. package/dist/components/trip-cards/__tests__/TripCardsLayout.test.js +277 -0
  46. package/dist/components/trip-cards/__tests__/assets.test.d.ts +1 -0
  47. package/dist/components/trip-cards/__tests__/assets.test.js +165 -0
  48. package/dist/components/trip-cards/__tests__/helpers.test.d.ts +1 -0
  49. package/dist/components/trip-cards/__tests__/helpers.test.js +135 -0
  50. package/dist/components/trip-cards/__tests__/index.test.d.ts +1 -0
  51. package/dist/components/trip-cards/__tests__/index.test.js +437 -0
  52. package/dist/components/trip-cards/__tests__/mockData.test.d.ts +1 -0
  53. package/dist/components/trip-cards/__tests__/mockData.test.js +57 -0
  54. package/dist/components/trip-cards/__tests__/skeletonStyles.test.d.ts +1 -0
  55. package/dist/components/trip-cards/__tests__/skeletonStyles.test.js +194 -0
  56. package/dist/components/trip-cards/assets/BoatIcon.d.ts +1 -0
  57. package/dist/components/trip-cards/assets/BoatIcon.js +4 -0
  58. package/dist/components/trip-cards/assets/CalendarIcon.d.ts +1 -0
  59. package/dist/components/trip-cards/assets/CalendarIcon.js +4 -0
  60. package/dist/components/trip-cards/assets/ChevronRightIcon.d.ts +1 -0
  61. package/dist/components/trip-cards/assets/ChevronRightIcon.js +4 -0
  62. package/dist/components/trip-cards/assets/LocationIcon.d.ts +1 -0
  63. package/dist/components/trip-cards/assets/LocationIcon.js +4 -0
  64. package/dist/components/trip-cards/assets/MoonIcon.d.ts +1 -0
  65. package/dist/components/trip-cards/assets/MoonIcon.js +4 -0
  66. package/dist/components/trip-cards/assets/index.d.ts +6 -0
  67. package/dist/components/trip-cards/assets/index.js +7 -0
  68. package/dist/components/trip-cards/helpers.d.ts +4 -0
  69. package/dist/components/trip-cards/helpers.js +74 -0
  70. package/dist/components/trip-cards/index.d.ts +4 -0
  71. package/dist/components/trip-cards/index.js +70 -0
  72. package/dist/components/trip-cards/mockData.d.ts +3 -0
  73. package/dist/components/trip-cards/mockData.js +323 -0
  74. package/dist/components/trip-cards/skeletonStyles.d.ts +9 -0
  75. package/dist/components/trip-cards/skeletonStyles.js +37 -0
  76. package/dist/components/trip-cards/styles.d.ts +39 -0
  77. package/dist/components/trip-cards/styles.js +387 -0
  78. package/dist/components/trip-cards/types.d.ts +87 -0
  79. package/dist/components/trip-cards/types.js +2 -0
  80. package/dist/index.d.ts +1 -0
  81. package/dist/index.js +2 -1
  82. package/package.json +3 -3
  83. package/rnw.js +1 -1
  84. package/src/components/carousel-component/CarouselComponent.stories.tsx +220 -0
  85. package/src/components/carousel-component/CarouselItem.tsx +20 -0
  86. package/src/components/carousel-component/DefaultNavigationArrow.tsx +37 -0
  87. package/src/components/carousel-component/DefaultPageDot.tsx +20 -0
  88. package/src/components/carousel-component/__tests__/CarouselComponent.test.tsx +259 -0
  89. package/src/components/carousel-component/__tests__/CarouselItem.test.tsx +140 -0
  90. package/src/components/carousel-component/__tests__/DefaultNavigationArrow.test.tsx +153 -0
  91. package/src/components/carousel-component/__tests__/DefaultPageDot.test.tsx +105 -0
  92. package/src/components/carousel-component/hooks/__tests__/useCarousel.test.ts +438 -0
  93. package/src/components/carousel-component/hooks/useCarousel.ts +187 -0
  94. package/src/components/carousel-component/index.tsx +88 -0
  95. package/src/components/carousel-component/styles.ts +140 -0
  96. package/src/components/carousel-component/types.ts +51 -0
  97. package/src/components/opta/cricket/scorecard/OptaCricketScorecard.tsx +0 -13
  98. package/src/components/opta/cricket/scorecard/__tests__/OptaCricketScorecard.test.tsx +16 -126
  99. package/src/components/opta/cricket/scorecard/__tests__/__snapshots__/OptaCricketScorecard.test.tsx.snap +6 -5
  100. package/src/components/opta/football/summary/OptaFootballSummary.tsx +0 -13
  101. package/src/components/opta/football/summary/__tests__/OptaFootballSummary.test.tsx +18 -127
  102. package/src/components/opta/football/summary/__tests__/__snapshots__/OptaFootballSummary.test.tsx.snap +6 -5
  103. package/src/components/opta/rugby/summary/OptaRugbySummary.tsx +0 -13
  104. package/src/components/opta/rugby/summary/__tests__/OptaRugbySummary.test.tsx +17 -127
  105. package/src/components/opta/rugby/summary/__tests__/__snapshots__/OptaRugbySummary.test.tsx.snap +6 -5
  106. package/src/components/trip-cards/SkeletonCard.tsx +54 -0
  107. package/src/components/trip-cards/TripCard.tsx +135 -0
  108. package/src/components/trip-cards/TripCards.stories.tsx +67 -0
  109. package/src/components/trip-cards/TripCardsLayout.tsx +75 -0
  110. package/src/components/trip-cards/__tests__/SkeletonCard.test.tsx +169 -0
  111. package/src/components/trip-cards/__tests__/TripCard.test.tsx +120 -0
  112. package/src/components/trip-cards/__tests__/TripCardsLayout.test.tsx +532 -0
  113. package/src/components/trip-cards/__tests__/assets.test.tsx +206 -0
  114. package/src/components/trip-cards/__tests__/helpers.test.ts +165 -0
  115. package/src/components/trip-cards/__tests__/index.test.tsx +499 -0
  116. package/src/components/trip-cards/__tests__/mockData.test.ts +67 -0
  117. package/src/components/trip-cards/__tests__/skeletonStyles.test.tsx +256 -0
  118. package/src/components/trip-cards/assets/BoatIcon.tsx +17 -0
  119. package/src/components/trip-cards/assets/CalendarIcon.tsx +17 -0
  120. package/src/components/trip-cards/assets/ChevronRightIcon.tsx +20 -0
  121. package/src/components/trip-cards/assets/LocationIcon.tsx +17 -0
  122. package/src/components/trip-cards/assets/MoonIcon.tsx +17 -0
  123. package/src/components/trip-cards/assets/index.ts +7 -0
  124. package/src/components/trip-cards/helpers.ts +99 -0
  125. package/src/components/trip-cards/index.tsx +104 -0
  126. package/src/components/trip-cards/mockData.ts +351 -0
  127. package/src/components/trip-cards/skeletonStyles.ts +46 -0
  128. package/src/components/trip-cards/styles.ts +426 -0
  129. package/src/components/trip-cards/types.ts +91 -0
  130. package/src/index.ts +2 -0
  131. package/dist/components/opta/utils/__tests__/emitEvent.test.js +0 -264
  132. package/dist/components/opta/utils/emitEvent.d.ts +0 -1
  133. package/dist/components/opta/utils/emitEvent.js +0 -9
  134. package/src/components/opta/utils/__tests__/emitEvent.test.tsx +0 -415
  135. package/src/components/opta/utils/emitEvent.ts +0 -11
  136. /package/dist/components/{opta/utils/__tests__/emitEvent.test.d.ts → carousel-component/CarouselComponent.stories.d.ts} +0 -0
@@ -7,16 +7,17 @@ exports[`OptaCricketScorecard should render correctly 1`] = `
7
7
  >
8
8
  <div
9
9
  class="sc-bxivhb sc-ifAKCX dNXXXn"
10
- >
11
- <div>
12
- Widget
13
- </div>
14
- </div>
10
+ />
15
11
  <button
16
12
  class="sc-EHOje dWKhuC"
17
13
  >
18
14
  Show Details
19
15
  </button>
16
+ <div
17
+ class="sc-bwzfXH eSqyJ"
18
+ >
19
+ Placeholder
20
+ </div>
20
21
  </div>
21
22
  </DocumentFragment>
22
23
  `;
@@ -13,7 +13,6 @@ import {
13
13
  import { Container, PlaceholderContainer } from '../../shared/shared-styles';
14
14
  import { WidgetContainer } from '../../shared/summary-styles';
15
15
  import Button from '../../shared/button/Button';
16
- import { emitEvent } from '../../utils/emitEvent';
17
16
 
18
17
  export const OptaFootballSummary: React.FC<{
19
18
  season: string;
@@ -34,7 +33,6 @@ export const OptaFootballSummary: React.FC<{
34
33
  heightLg = 197
35
34
  }) => {
36
35
  const ref = React.createRef<HTMLDivElement>();
37
- const containerRef = React.createRef<HTMLDivElement>();
38
36
  const [isReady, setIsReady] = useState<boolean>(false);
39
37
  const [showDetails, setShowDetails] = useState<boolean>(false);
40
38
 
@@ -73,16 +71,6 @@ export const OptaFootballSummary: React.FC<{
73
71
  });
74
72
  }, []);
75
73
 
76
- useEffect(
77
- () => {
78
- const height = containerRef.current
79
- ? containerRef.current.offsetHeight
80
- : 0;
81
- emitEvent('updateHeight', height);
82
- },
83
- [showDetails]
84
- );
85
-
86
74
  return (
87
75
  <Container
88
76
  fullWidth={full_width}
@@ -90,7 +78,6 @@ export const OptaFootballSummary: React.FC<{
90
78
  heightMd={heightMd}
91
79
  heightLg={heightLg}
92
80
  hasPadding
93
- ref={containerRef}
94
81
  >
95
82
  <WidgetContainer ref={ref} showDetails={showDetails} />
96
83
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { render, act, fireEvent, waitFor } from '@testing-library/react';
2
+ import { render, act, fireEvent } from '@testing-library/react';
3
+
3
4
  import 'regenerator-runtime';
4
5
  import '@testing-library/jest-dom';
5
6
 
@@ -10,27 +11,22 @@ jest.mock('@times-components/image', () => ({
10
11
  const mockInitSettings = jest.fn();
11
12
  const mockInitStyleSheet = jest.fn();
12
13
  const mockInitComponent = jest.fn();
13
- const mockInitScript = jest.fn();
14
- const mockEmitEvent = jest.fn();
14
+ const mockHasMatchEvents = jest.fn();
15
15
 
16
- const mockInitElement = jest.fn(() => {
16
+ const mockInitElement = () => {
17
17
  const element = document.createElement('div');
18
18
  element.appendChild(document.createTextNode('Widget'));
19
19
  return element;
20
- });
20
+ };
21
21
 
22
22
  jest.mock('../../../utils/config', () => ({
23
23
  initSettings: mockInitSettings,
24
24
  initStyleSheet: mockInitStyleSheet,
25
- initScript: mockInitScript,
25
+ initScript: () => new Promise(resolve => resolve({})),
26
26
  initElement: mockInitElement,
27
27
  initComponent: mockInitComponent
28
28
  }));
29
29
 
30
- jest.mock('../../../utils/emitEvent', () => ({
31
- emitEvent: mockEmitEvent
32
- }));
33
-
34
30
  import { OptaFootballSummary } from '../OptaFootballSummary';
35
31
 
36
32
  const requiredProps = {
@@ -42,142 +38,37 @@ const requiredProps = {
42
38
  describe('OptaFootballSummary', () => {
43
39
  beforeEach(() => {
44
40
  jest.clearAllMocks();
45
- mockInitScript.mockResolvedValue({});
46
- });
47
-
48
- afterEach(() => {
49
- jest.clearAllMocks();
50
- document.body.innerHTML = '';
51
41
  });
52
42
 
53
43
  it('should render correctly', async () => {
54
- const { asFragment, getByRole } = render(
55
- <OptaFootballSummary {...requiredProps} />
56
- );
44
+ const { asFragment } = render(<OptaFootballSummary {...requiredProps} />);
57
45
 
58
- await waitFor(() => {
59
- expect(mockInitSettings).toHaveBeenCalledTimes(1);
46
+ act(() => {
47
+ mockInitComponent();
48
+ mockHasMatchEvents();
60
49
  });
61
50
 
62
- expect(mockInitStyleSheet).toHaveBeenCalledWith('football');
51
+ expect(mockInitSettings).toHaveBeenCalledTimes(1);
52
+ expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
63
53
  expect(mockInitComponent).toHaveBeenCalledTimes(1);
64
- expect(getByRole('button')).toBeInTheDocument();
65
54
 
66
55
  expect(asFragment()).toMatchSnapshot();
67
56
  });
68
57
 
69
- it('should enable the button initially', () => {
58
+ it('should disable the button initially', () => {
70
59
  const { getByRole } = render(<OptaFootballSummary {...requiredProps} />);
71
60
  const button = getByRole('button');
72
61
  expect(button).not.toBeDisabled();
73
62
  });
74
63
 
75
- it('should toggle details when button is clicked', async () => {
64
+ it('should toggle details when button is clicked', () => {
76
65
  const { getByRole } = render(<OptaFootballSummary {...requiredProps} />);
77
66
  const button = getByRole('button');
78
67
 
79
68
  expect(button).toHaveTextContent('Show Details');
80
-
81
- act(() => {
82
- fireEvent.click(button);
83
- });
84
-
85
- await waitFor(() => {
86
- expect(button).toHaveTextContent('Hide Details');
87
- });
88
-
89
- act(() => {
90
- fireEvent.click(button);
91
- });
92
-
93
- await waitFor(() => {
94
- expect(button).toHaveTextContent('Show Details');
95
- });
96
- });
97
-
98
- describe('emitEvent', () => {
99
- it('should call emitEvent with updateHeight when details are toggled', async () => {
100
- const { getByRole } = render(<OptaFootballSummary {...requiredProps} />);
101
- const button = getByRole('button');
102
-
103
- // Clear initial calls
104
- jest.clearAllMocks();
105
-
106
- act(() => {
107
- fireEvent.click(button);
108
- });
109
-
110
- await waitFor(() => {
111
- expect(mockEmitEvent).toHaveBeenCalledWith(
112
- 'updateHeight',
113
- expect.any(Number)
114
- );
115
- });
116
- });
117
-
118
- it('should emit updateHeight event on each toggle', async () => {
119
- const { getByRole } = render(<OptaFootballSummary {...requiredProps} />);
120
- const button = getByRole('button');
121
-
122
- // Clear initial calls
123
- jest.clearAllMocks();
124
-
125
- // First toggle
126
- act(() => {
127
- fireEvent.click(button);
128
- });
129
-
130
- await waitFor(() => {
131
- expect(mockEmitEvent).toHaveBeenCalledTimes(1);
132
- });
133
-
134
- // Second toggle
135
- act(() => {
136
- fireEvent.click(button);
137
- });
138
-
139
- await waitFor(() => {
140
- expect(mockEmitEvent).toHaveBeenCalledTimes(2);
141
- });
142
-
143
- // Third toggle
144
- act(() => {
145
- fireEvent.click(button);
146
- });
147
-
148
- await waitFor(() => {
149
- expect(mockEmitEvent).toHaveBeenCalledTimes(3);
150
- });
151
- });
152
-
153
- it('should emit updateHeight with container offsetHeight', async () => {
154
- const { getByRole, container } = render(
155
- <OptaFootballSummary {...requiredProps} />
156
- );
157
- const button = getByRole('button');
158
-
159
- // Clear initial calls
160
- jest.clearAllMocks();
161
-
162
- // Mock offsetHeight
163
- const containerElement = container.querySelector('[class*="Container"]');
164
- if (containerElement) {
165
- Object.defineProperty(containerElement, 'offsetHeight', {
166
- value: 250,
167
- configurable: true
168
- });
169
- }
170
-
171
- act(() => {
172
- fireEvent.click(button);
173
- });
174
-
175
- await waitFor(() => {
176
- expect(mockEmitEvent).toHaveBeenCalledWith(
177
- 'updateHeight',
178
- expect.any(Number)
179
- );
180
- });
181
- });
69
+ fireEvent.click(button);
70
+ expect(button).toHaveTextContent('Hide Details');
71
+ fireEvent.click(button);
72
+ expect(button).toHaveTextContent('Show Details');
182
73
  });
183
74
  });
@@ -7,16 +7,17 @@ exports[`OptaFootballSummary should render correctly 1`] = `
7
7
  >
8
8
  <div
9
9
  class="sc-htpNat sc-bxivhb hNtyxM"
10
- >
11
- <div>
12
- Widget
13
- </div>
14
- </div>
10
+ />
15
11
  <button
16
12
  class="sc-ifAKCX fvBTJK"
17
13
  >
18
14
  Show Details
19
15
  </button>
16
+ <div
17
+ class="sc-bwzfXH eSqyJ"
18
+ >
19
+ Placeholder
20
+ </div>
20
21
  </div>
21
22
  </DocumentFragment>
22
23
  `;
@@ -13,7 +13,6 @@ import {
13
13
  import { Container, PlaceholderContainer } from '../../shared/shared-styles';
14
14
  import { WidgetContainer } from '../../shared/summary-styles';
15
15
  import Button from '../../shared/button/Button';
16
- import { emitEvent } from '../../utils/emitEvent';
17
16
 
18
17
  export const OptaRugbySummary: React.FC<{
19
18
  season: string;
@@ -34,7 +33,6 @@ export const OptaRugbySummary: React.FC<{
34
33
  heightLg = 197
35
34
  }) => {
36
35
  const ref = React.createRef<HTMLDivElement>();
37
- const containerRef = React.createRef<HTMLDivElement>();
38
36
  const [isReady, setIsReady] = useState<boolean>(false);
39
37
  const [showDetails, setShowDetails] = useState<boolean>(false);
40
38
 
@@ -75,16 +73,6 @@ export const OptaRugbySummary: React.FC<{
75
73
  });
76
74
  }, []);
77
75
 
78
- useEffect(
79
- () => {
80
- const height = containerRef.current
81
- ? containerRef.current.offsetHeight
82
- : 0;
83
- emitEvent('updateHeight', height);
84
- },
85
- [showDetails]
86
- );
87
-
88
76
  return (
89
77
  <Container
90
78
  fullWidth={full_width}
@@ -92,7 +80,6 @@ export const OptaRugbySummary: React.FC<{
92
80
  heightMd={heightMd}
93
81
  heightLg={heightLg}
94
82
  hasPadding
95
- ref={containerRef}
96
83
  >
97
84
  <WidgetContainer ref={ref} showDetails={showDetails} />
98
85
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { render, act, fireEvent, waitFor } from '@testing-library/react';
2
+ import { render, act, fireEvent } from '@testing-library/react';
3
+
3
4
  import 'regenerator-runtime';
4
5
  import '@testing-library/jest-dom';
5
6
 
@@ -10,27 +11,22 @@ jest.mock('@times-components/image', () => ({
10
11
  const mockInitSettings = jest.fn();
11
12
  const mockInitStyleSheet = jest.fn();
12
13
  const mockInitComponent = jest.fn();
13
- const mockInitScript = jest.fn();
14
- const mockEmitEvent = jest.fn();
14
+ const mockHasMatchEvents = jest.fn();
15
15
 
16
- const mockInitElement = jest.fn(() => {
16
+ const mockInitElement = () => {
17
17
  const element = document.createElement('div');
18
18
  element.appendChild(document.createTextNode('Widget'));
19
19
  return element;
20
- });
20
+ };
21
21
 
22
22
  jest.mock('../../../utils/config', () => ({
23
23
  initSettings: mockInitSettings,
24
24
  initStyleSheet: mockInitStyleSheet,
25
- initScript: mockInitScript,
25
+ initScript: () => new Promise(resolve => resolve({})),
26
26
  initElement: mockInitElement,
27
27
  initComponent: mockInitComponent
28
28
  }));
29
29
 
30
- jest.mock('../../../utils/emitEvent', () => ({
31
- emitEvent: mockEmitEvent
32
- }));
33
-
34
30
  import { OptaRugbySummary } from '../OptaRugbySummary';
35
31
 
36
32
  const requiredProps = {
@@ -38,30 +34,22 @@ const requiredProps = {
38
34
  competition: '209',
39
35
  match: '921100'
40
36
  };
41
-
42
37
  describe('OptaRugbySummary', () => {
43
38
  beforeEach(() => {
44
39
  jest.clearAllMocks();
45
- mockInitScript.mockResolvedValue({});
46
- });
47
-
48
- afterEach(() => {
49
- jest.clearAllMocks();
50
- document.body.innerHTML = '';
51
40
  });
52
41
 
53
42
  it('should render correctly', async () => {
54
- const { asFragment, getByRole } = render(
55
- <OptaRugbySummary {...requiredProps} />
56
- );
43
+ const { asFragment } = render(<OptaRugbySummary {...requiredProps} />);
57
44
 
58
- await waitFor(() => {
59
- expect(mockInitSettings).toHaveBeenCalledTimes(1);
45
+ act(() => {
46
+ mockInitComponent();
47
+ mockHasMatchEvents();
60
48
  });
61
49
 
62
- expect(mockInitStyleSheet).toHaveBeenCalledWith('rugby');
50
+ expect(mockInitSettings).toHaveBeenCalledTimes(1);
51
+ expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
63
52
  expect(mockInitComponent).toHaveBeenCalledTimes(1);
64
- expect(getByRole('button')).toBeInTheDocument();
65
53
 
66
54
  expect(asFragment()).toMatchSnapshot();
67
55
  });
@@ -72,112 +60,14 @@ describe('OptaRugbySummary', () => {
72
60
  expect(button).not.toBeDisabled();
73
61
  });
74
62
 
75
- it('should toggle details when button is clicked', async () => {
63
+ it('should toggle details when button is clicked', () => {
76
64
  const { getByRole } = render(<OptaRugbySummary {...requiredProps} />);
77
65
  const button = getByRole('button');
78
66
 
79
67
  expect(button).toHaveTextContent('Show Details');
80
-
81
- act(() => {
82
- fireEvent.click(button);
83
- });
84
-
85
- await waitFor(() => {
86
- expect(button).toHaveTextContent('Hide Details');
87
- });
88
-
89
- act(() => {
90
- fireEvent.click(button);
91
- });
92
-
93
- await waitFor(() => {
94
- expect(button).toHaveTextContent('Show Details');
95
- });
96
- });
97
-
98
- describe('emitEvent', () => {
99
- it('should call emitEvent with updateHeight when details are toggled', async () => {
100
- const { getByRole } = render(<OptaRugbySummary {...requiredProps} />);
101
- const button = getByRole('button');
102
-
103
- // Clear initial calls
104
- jest.clearAllMocks();
105
-
106
- act(() => {
107
- fireEvent.click(button);
108
- });
109
-
110
- await waitFor(() => {
111
- expect(mockEmitEvent).toHaveBeenCalledWith(
112
- 'updateHeight',
113
- expect.any(Number)
114
- );
115
- });
116
- });
117
-
118
- it('should emit updateHeight event on each toggle', async () => {
119
- const { getByRole } = render(<OptaRugbySummary {...requiredProps} />);
120
- const button = getByRole('button');
121
-
122
- // Clear initial calls
123
- jest.clearAllMocks();
124
-
125
- // First toggle
126
- act(() => {
127
- fireEvent.click(button);
128
- });
129
-
130
- await waitFor(() => {
131
- expect(mockEmitEvent).toHaveBeenCalledTimes(1);
132
- });
133
-
134
- // Second toggle
135
- act(() => {
136
- fireEvent.click(button);
137
- });
138
-
139
- await waitFor(() => {
140
- expect(mockEmitEvent).toHaveBeenCalledTimes(2);
141
- });
142
-
143
- // Third toggle
144
- act(() => {
145
- fireEvent.click(button);
146
- });
147
-
148
- await waitFor(() => {
149
- expect(mockEmitEvent).toHaveBeenCalledTimes(3);
150
- });
151
- });
152
-
153
- it('should emit updateHeight with container offsetHeight', async () => {
154
- const { getByRole, container } = render(
155
- <OptaRugbySummary {...requiredProps} />
156
- );
157
- const button = getByRole('button');
158
-
159
- // Clear initial calls
160
- jest.clearAllMocks();
161
-
162
- // Mock offsetHeight
163
- const containerElement = container.querySelector('[class*="Container"]');
164
- if (containerElement) {
165
- Object.defineProperty(containerElement, 'offsetHeight', {
166
- value: 250,
167
- configurable: true
168
- });
169
- }
170
-
171
- act(() => {
172
- fireEvent.click(button);
173
- });
174
-
175
- await waitFor(() => {
176
- expect(mockEmitEvent).toHaveBeenCalledWith(
177
- 'updateHeight',
178
- expect.any(Number)
179
- );
180
- });
181
- });
68
+ fireEvent.click(button);
69
+ expect(button).toHaveTextContent('Hide Details');
70
+ fireEvent.click(button);
71
+ expect(button).toHaveTextContent('Show Details');
182
72
  });
183
73
  });
@@ -7,16 +7,17 @@ exports[`OptaRugbySummary should render correctly 1`] = `
7
7
  >
8
8
  <div
9
9
  class="sc-htpNat sc-bxivhb hNtyxM"
10
- >
11
- <div>
12
- Widget
13
- </div>
14
- </div>
10
+ />
15
11
  <button
16
12
  class="sc-ifAKCX fvBTJK"
17
13
  >
18
14
  Show Details
19
15
  </button>
16
+ <div
17
+ class="sc-bwzfXH eSqyJ"
18
+ >
19
+ Placeholder
20
+ </div>
20
21
  </div>
21
22
  </DocumentFragment>
22
23
  `;
@@ -0,0 +1,54 @@
1
+ import React, { FC } from 'react';
2
+ import { Placeholder } from '@times-components/image';
3
+ import {
4
+ CardContainer,
5
+ ImageContainer,
6
+ CardContent,
7
+ TopContainer,
8
+ BottomContainer,
9
+ DataPointsList,
10
+ DataPoint,
11
+ PriceSection,
12
+ PriceContainer
13
+ } from './styles';
14
+ import {
15
+ SkeletonLine,
16
+ SkeletonHeadline,
17
+ SkeletonPrice,
18
+ SkeletonButton
19
+ } from './skeletonStyles';
20
+
21
+ export const SkeletonCard: FC = () => {
22
+ return (
23
+ <CardContainer data-testid="skeleton-card-container">
24
+ <ImageContainer data-testid="skeleton-image-container">
25
+ <Placeholder />
26
+ </ImageContainer>
27
+ <CardContent data-testid="skeleton-card-content">
28
+ <TopContainer data-testid="skeleton-top-container">
29
+ <SkeletonHeadline data-testid="skeleton-headline" />
30
+ <DataPointsList data-testid="skeleton-data-points-list">
31
+ {[1, 2, 3, 4].map(i => (
32
+ <DataPoint key={i} data-testid={`skeleton-data-point-${i}`}>
33
+ <SkeletonLine width="80px" data-testid={`skeleton-line-${i}`} />
34
+ </DataPoint>
35
+ ))}
36
+ </DataPointsList>
37
+ </TopContainer>
38
+ <BottomContainer data-testid="skeleton-bottom-container">
39
+ <PriceSection data-testid="skeleton-price-section">
40
+ <PriceContainer data-testid="skeleton-price-container">
41
+ <SkeletonLine
42
+ width="40px"
43
+ marginBottom="4px"
44
+ data-testid="skeleton-price-label"
45
+ />
46
+ <SkeletonPrice data-testid="skeleton-price" />
47
+ </PriceContainer>
48
+ </PriceSection>
49
+ <SkeletonButton as="div" data-testid="skeleton-button" />
50
+ </BottomContainer>
51
+ </CardContent>
52
+ </CardContainer>
53
+ );
54
+ };