@times-components/ts-components 1.145.1-777882a8b99dc7733f00b94202a91fa8b7dc2a7e.1 → 1.145.1-b32ea924749bafdf12e3e8515023538fa20e7808.3

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 (54) hide show
  1. package/dist/components/opta/cricket/scorecard/OptaCricketScorecard.js +10 -2
  2. package/dist/components/opta/cricket/scorecard/__tests__/OptaCricketScorecard.test.js +94 -17
  3. package/dist/components/opta/football/opta-match-stats/shared/styles.js +1 -8
  4. package/dist/components/opta/football/summary/OptaFootballSummary.js +10 -2
  5. package/dist/components/opta/football/summary/__tests__/OptaFootballSummary.test.js +95 -18
  6. package/dist/components/opta/rugby/summary/OptaRugbySummary.js +10 -2
  7. package/dist/components/opta/rugby/summary/__tests__/OptaRugbySummary.test.js +94 -17
  8. package/dist/components/opta/utils/__tests__/emitEvent.test.js +264 -0
  9. package/dist/components/opta/utils/emitEvent.d.ts +1 -0
  10. package/dist/components/opta/utils/emitEvent.js +9 -0
  11. package/dist/index.d.ts +0 -1
  12. package/dist/index.js +1 -2
  13. package/package.json +3 -3
  14. package/rnw.js +1 -1
  15. package/src/components/opta/cricket/scorecard/OptaCricketScorecard.tsx +13 -0
  16. package/src/components/opta/cricket/scorecard/__tests__/OptaCricketScorecard.test.tsx +126 -16
  17. package/src/components/opta/cricket/scorecard/__tests__/__snapshots__/OptaCricketScorecard.test.tsx.snap +5 -6
  18. package/src/components/opta/football/opta-match-stats/commentary/__tests__/__snapshots__/OptaMatchStatsCommentary.test.tsx.snap +1 -1
  19. package/src/components/opta/football/opta-match-stats/shared/styles.ts +0 -8
  20. package/src/components/opta/football/opta-match-stats/stats-graphs/__tests__/__snapshots__/OptaMatchStatsGraphs.test.tsx.snap +1 -1
  21. package/src/components/opta/football/summary/OptaFootballSummary.tsx +13 -0
  22. package/src/components/opta/football/summary/__tests__/OptaFootballSummary.test.tsx +127 -18
  23. package/src/components/opta/football/summary/__tests__/__snapshots__/OptaFootballSummary.test.tsx.snap +5 -6
  24. package/src/components/opta/rugby/summary/OptaRugbySummary.tsx +13 -0
  25. package/src/components/opta/rugby/summary/__tests__/OptaRugbySummary.test.tsx +127 -17
  26. package/src/components/opta/rugby/summary/__tests__/__snapshots__/OptaRugbySummary.test.tsx.snap +5 -6
  27. package/src/components/opta/utils/__tests__/emitEvent.test.tsx +415 -0
  28. package/src/components/opta/utils/emitEvent.ts +11 -0
  29. package/src/index.ts +0 -3
  30. package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.d.ts +0 -10
  31. package/dist/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.js +0 -69
  32. package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.d.ts +0 -12
  33. package/dist/components/opta/football/opta-match-stats/matchday-live/MobileWidget.js +0 -90
  34. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.d.ts +0 -12
  35. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.js +0 -10
  36. package/dist/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.js +0 -24
  37. package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.d.ts +0 -2
  38. package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.js +0 -48
  39. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.d.ts +0 -1
  40. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.js +0 -19
  41. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.d.ts +0 -12
  42. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.js +0 -67
  43. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.d.ts +0 -6
  44. package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.js +0 -714
  45. package/src/components/opta/football/opta-match-stats/matchday-live/DesktopWidget.tsx +0 -108
  46. package/src/components/opta/football/opta-match-stats/matchday-live/MobileWidget.tsx +0 -158
  47. package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.tsx +0 -38
  48. package/src/components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.tsx +0 -23
  49. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/OptaMatchStatsMatchdayLive.test.tsx +0 -61
  50. package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/__snapshots__/OptaMatchStatsMatchdayLive.test.tsx.snap +0 -61
  51. package/src/components/opta/football/opta-match-stats/matchday-live/styles/MatchdayLiveController.tsx +0 -19
  52. package/src/components/opta/football/opta-match-stats/matchday-live/styles/NavigationWrapper.tsx +0 -81
  53. package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx +0 -745
  54. /package/dist/components/opta/{football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive.stories.d.ts → utils/__tests__/emitEvent.test.d.ts} +0 -0
@@ -12,6 +12,7 @@ import {
12
12
  import { Container, PlaceholderContainer } from '../../shared/shared-styles';
13
13
  import { WidgetContainer } from './styles';
14
14
  import Button from '../../shared/button/Button';
15
+ import { emitEvent } from '../../utils/emitEvent';
15
16
 
16
17
  export const OptaCricketScorecard: React.FC<{
17
18
  competition: string;
@@ -30,6 +31,7 @@ export const OptaCricketScorecard: React.FC<{
30
31
  heightLg = 258
31
32
  }) => {
32
33
  const ref = React.createRef<HTMLDivElement>();
34
+ const containerRef = React.createRef<HTMLDivElement>();
33
35
  const [isReady, setIsReady] = useState<boolean>(false);
34
36
  const [showDetails, setShowDetails] = useState<boolean>(false);
35
37
 
@@ -81,6 +83,16 @@ export const OptaCricketScorecard: React.FC<{
81
83
  });
82
84
  }, []);
83
85
 
86
+ useEffect(
87
+ () => {
88
+ const height = containerRef.current
89
+ ? containerRef.current.offsetHeight
90
+ : 0;
91
+ emitEvent('updateHeight', height);
92
+ },
93
+ [showDetails]
94
+ );
95
+
84
96
  return (
85
97
  <Container
86
98
  fullWidth={full_width}
@@ -88,6 +100,7 @@ export const OptaCricketScorecard: React.FC<{
88
100
  heightMd={heightMd}
89
101
  heightLg={heightLg}
90
102
  hasPadding
103
+ ref={containerRef}
91
104
  >
92
105
  <WidgetContainer ref={ref} showDetails={showDetails} />
93
106
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { render, act, fireEvent } from '@testing-library/react';
2
+ import { render, act, fireEvent, waitFor } from '@testing-library/react';
3
3
  import 'regenerator-runtime';
4
4
  import '@testing-library/jest-dom';
5
5
 
@@ -10,22 +10,27 @@ jest.mock('@times-components/image', () => ({
10
10
  const mockInitSettings = jest.fn();
11
11
  const mockInitStyleSheet = jest.fn();
12
12
  const mockInitComponent = jest.fn();
13
- const mockHasMatchEvents = jest.fn();
13
+ const mockInitScript = jest.fn();
14
+ const mockEmitEvent = jest.fn();
14
15
 
15
- const mockInitElement = () => {
16
+ const mockInitElement = jest.fn(() => {
16
17
  const element = document.createElement('div');
17
18
  element.appendChild(document.createTextNode('Widget'));
18
19
  return element;
19
- };
20
+ });
20
21
 
21
22
  jest.mock('../../../utils/config', () => ({
22
23
  initSettings: mockInitSettings,
23
24
  initStyleSheet: mockInitStyleSheet,
24
- initScript: () => new Promise(resolve => resolve({})),
25
+ initScript: mockInitScript,
25
26
  initElement: mockInitElement,
26
27
  initComponent: mockInitComponent
27
28
  }));
28
29
 
30
+ jest.mock('../../../utils/emitEvent', () => ({
31
+ emitEvent: mockEmitEvent
32
+ }));
33
+
29
34
  import { OptaCricketScorecard } from '../OptaCricketScorecard';
30
35
 
31
36
  const requiredProps = {
@@ -36,19 +41,26 @@ const requiredProps = {
36
41
  describe('OptaCricketScorecard', () => {
37
42
  beforeEach(() => {
38
43
  jest.clearAllMocks();
44
+ mockInitScript.mockResolvedValue({});
45
+ });
46
+
47
+ afterEach(() => {
48
+ jest.clearAllMocks();
49
+ document.body.innerHTML = '';
39
50
  });
40
51
 
41
52
  it('should render correctly', async () => {
42
- const { asFragment } = render(<OptaCricketScorecard {...requiredProps} />);
53
+ const { asFragment, getByRole } = render(
54
+ <OptaCricketScorecard {...requiredProps} />
55
+ );
43
56
 
44
- act(() => {
45
- mockInitComponent();
46
- mockHasMatchEvents();
57
+ await waitFor(() => {
58
+ expect(mockInitSettings).toHaveBeenCalledTimes(1);
47
59
  });
48
60
 
49
- expect(mockInitSettings).toHaveBeenCalledTimes(1);
50
- expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
61
+ expect(mockInitStyleSheet).toHaveBeenCalledWith('cricket');
51
62
  expect(mockInitComponent).toHaveBeenCalledTimes(1);
63
+ expect(getByRole('button')).toBeInTheDocument();
52
64
 
53
65
  expect(asFragment()).toMatchSnapshot();
54
66
  });
@@ -59,14 +71,112 @@ describe('OptaCricketScorecard', () => {
59
71
  expect(button).not.toBeDisabled();
60
72
  });
61
73
 
62
- it('should toggle details when button is clicked', () => {
74
+ it('should toggle details when button is clicked', async () => {
63
75
  const { getByRole } = render(<OptaCricketScorecard {...requiredProps} />);
64
76
  const button = getByRole('button');
65
77
 
66
78
  expect(button).toHaveTextContent('Show Details');
67
- fireEvent.click(button);
68
- expect(button).toHaveTextContent('Hide Details');
69
- fireEvent.click(button);
70
- expect(button).toHaveTextContent('Show Details');
79
+
80
+ act(() => {
81
+ fireEvent.click(button);
82
+ });
83
+
84
+ await waitFor(() => {
85
+ expect(button).toHaveTextContent('Hide Details');
86
+ });
87
+
88
+ act(() => {
89
+ fireEvent.click(button);
90
+ });
91
+
92
+ await waitFor(() => {
93
+ expect(button).toHaveTextContent('Show Details');
94
+ });
95
+ });
96
+
97
+ describe('emitEvent', () => {
98
+ it('should call emitEvent with updateHeight when details are toggled', async () => {
99
+ const { getByRole } = render(<OptaCricketScorecard {...requiredProps} />);
100
+ const button = getByRole('button');
101
+
102
+ // Clear initial calls
103
+ jest.clearAllMocks();
104
+
105
+ act(() => {
106
+ fireEvent.click(button);
107
+ });
108
+
109
+ await waitFor(() => {
110
+ expect(mockEmitEvent).toHaveBeenCalledWith(
111
+ 'updateHeight',
112
+ expect.any(Number)
113
+ );
114
+ });
115
+ });
116
+
117
+ it('should emit updateHeight event on each toggle', async () => {
118
+ const { getByRole } = render(<OptaCricketScorecard {...requiredProps} />);
119
+ const button = getByRole('button');
120
+
121
+ // Clear initial calls
122
+ jest.clearAllMocks();
123
+
124
+ // First toggle
125
+ act(() => {
126
+ fireEvent.click(button);
127
+ });
128
+
129
+ await waitFor(() => {
130
+ expect(mockEmitEvent).toHaveBeenCalledTimes(1);
131
+ });
132
+
133
+ // Second toggle
134
+ act(() => {
135
+ fireEvent.click(button);
136
+ });
137
+
138
+ await waitFor(() => {
139
+ expect(mockEmitEvent).toHaveBeenCalledTimes(2);
140
+ });
141
+
142
+ // Third toggle
143
+ act(() => {
144
+ fireEvent.click(button);
145
+ });
146
+
147
+ await waitFor(() => {
148
+ expect(mockEmitEvent).toHaveBeenCalledTimes(3);
149
+ });
150
+ });
151
+
152
+ it('should emit updateHeight with container offsetHeight', async () => {
153
+ const { getByRole, container } = render(
154
+ <OptaCricketScorecard {...requiredProps} />
155
+ );
156
+ const button = getByRole('button');
157
+
158
+ // Clear initial calls
159
+ jest.clearAllMocks();
160
+
161
+ // Mock offsetHeight
162
+ const containerElement = container.querySelector('[class*="Container"]');
163
+ if (containerElement) {
164
+ Object.defineProperty(containerElement, 'offsetHeight', {
165
+ value: 300,
166
+ configurable: true
167
+ });
168
+ }
169
+
170
+ act(() => {
171
+ fireEvent.click(button);
172
+ });
173
+
174
+ await waitFor(() => {
175
+ expect(mockEmitEvent).toHaveBeenCalledWith(
176
+ 'updateHeight',
177
+ expect.any(Number)
178
+ );
179
+ });
180
+ });
71
181
  });
72
182
  });
@@ -7,17 +7,16 @@ exports[`OptaCricketScorecard should render correctly 1`] = `
7
7
  >
8
8
  <div
9
9
  class="sc-bxivhb sc-ifAKCX dNXXXn"
10
- />
10
+ >
11
+ <div>
12
+ Widget
13
+ </div>
14
+ </div>
11
15
  <button
12
16
  class="sc-EHOje dWKhuC"
13
17
  >
14
18
  Show Details
15
19
  </button>
16
- <div
17
- class="sc-bwzfXH eSqyJ"
18
- >
19
- Placeholder
20
- </div>
21
20
  </div>
22
21
  </DocumentFragment>
23
22
  `;
@@ -3,7 +3,7 @@
3
3
  exports[`OptaMatchStatsCommentary renders and initialises widget 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
- class="sc-bxivhb eKHCQT"
6
+ class="sc-bxivhb hlADP"
7
7
  >
8
8
  <h3>
9
9
  Commentary
@@ -54,13 +54,5 @@ export const WidgetWrapper = styled.div<{
54
54
  @media (max-width: ${maxMDBreakpoint}px) {
55
55
  display: none;
56
56
  }
57
-
58
- ${props =>
59
- props.isApp &&
60
- `
61
- @media(prefers-color-scheme: dark) {
62
- color: ${darkTextColor} !important;
63
- }
64
- `}
65
57
  }
66
58
  `;
@@ -3,7 +3,7 @@
3
3
  exports[`OptaMatchStatsSummary should render correctly 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
- class="sc-bxivhb dwwqvg"
6
+ class="sc-bxivhb JyPwY"
7
7
  >
8
8
  <h3>
9
9
  Match Stats
@@ -13,6 +13,7 @@ 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';
16
17
 
17
18
  export const OptaFootballSummary: React.FC<{
18
19
  season: string;
@@ -33,6 +34,7 @@ export const OptaFootballSummary: React.FC<{
33
34
  heightLg = 197
34
35
  }) => {
35
36
  const ref = React.createRef<HTMLDivElement>();
37
+ const containerRef = React.createRef<HTMLDivElement>();
36
38
  const [isReady, setIsReady] = useState<boolean>(false);
37
39
  const [showDetails, setShowDetails] = useState<boolean>(false);
38
40
 
@@ -71,6 +73,16 @@ export const OptaFootballSummary: React.FC<{
71
73
  });
72
74
  }, []);
73
75
 
76
+ useEffect(
77
+ () => {
78
+ const height = containerRef.current
79
+ ? containerRef.current.offsetHeight
80
+ : 0;
81
+ emitEvent('updateHeight', height);
82
+ },
83
+ [showDetails]
84
+ );
85
+
74
86
  return (
75
87
  <Container
76
88
  fullWidth={full_width}
@@ -78,6 +90,7 @@ export const OptaFootballSummary: React.FC<{
78
90
  heightMd={heightMd}
79
91
  heightLg={heightLg}
80
92
  hasPadding
93
+ ref={containerRef}
81
94
  >
82
95
  <WidgetContainer ref={ref} showDetails={showDetails} />
83
96
 
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { render, act, fireEvent } from '@testing-library/react';
3
-
2
+ import { render, act, fireEvent, waitFor } from '@testing-library/react';
4
3
  import 'regenerator-runtime';
5
4
  import '@testing-library/jest-dom';
6
5
 
@@ -11,22 +10,27 @@ jest.mock('@times-components/image', () => ({
11
10
  const mockInitSettings = jest.fn();
12
11
  const mockInitStyleSheet = jest.fn();
13
12
  const mockInitComponent = jest.fn();
14
- const mockHasMatchEvents = jest.fn();
13
+ const mockInitScript = jest.fn();
14
+ const mockEmitEvent = jest.fn();
15
15
 
16
- const mockInitElement = () => {
16
+ const mockInitElement = jest.fn(() => {
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: () => new Promise(resolve => resolve({})),
25
+ initScript: mockInitScript,
26
26
  initElement: mockInitElement,
27
27
  initComponent: mockInitComponent
28
28
  }));
29
29
 
30
+ jest.mock('../../../utils/emitEvent', () => ({
31
+ emitEvent: mockEmitEvent
32
+ }));
33
+
30
34
  import { OptaFootballSummary } from '../OptaFootballSummary';
31
35
 
32
36
  const requiredProps = {
@@ -38,37 +42,142 @@ const requiredProps = {
38
42
  describe('OptaFootballSummary', () => {
39
43
  beforeEach(() => {
40
44
  jest.clearAllMocks();
45
+ mockInitScript.mockResolvedValue({});
46
+ });
47
+
48
+ afterEach(() => {
49
+ jest.clearAllMocks();
50
+ document.body.innerHTML = '';
41
51
  });
42
52
 
43
53
  it('should render correctly', async () => {
44
- const { asFragment } = render(<OptaFootballSummary {...requiredProps} />);
54
+ const { asFragment, getByRole } = render(
55
+ <OptaFootballSummary {...requiredProps} />
56
+ );
45
57
 
46
- act(() => {
47
- mockInitComponent();
48
- mockHasMatchEvents();
58
+ await waitFor(() => {
59
+ expect(mockInitSettings).toHaveBeenCalledTimes(1);
49
60
  });
50
61
 
51
- expect(mockInitSettings).toHaveBeenCalledTimes(1);
52
- expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
62
+ expect(mockInitStyleSheet).toHaveBeenCalledWith('football');
53
63
  expect(mockInitComponent).toHaveBeenCalledTimes(1);
64
+ expect(getByRole('button')).toBeInTheDocument();
54
65
 
55
66
  expect(asFragment()).toMatchSnapshot();
56
67
  });
57
68
 
58
- it('should disable the button initially', () => {
69
+ it('should enable the button initially', () => {
59
70
  const { getByRole } = render(<OptaFootballSummary {...requiredProps} />);
60
71
  const button = getByRole('button');
61
72
  expect(button).not.toBeDisabled();
62
73
  });
63
74
 
64
- it('should toggle details when button is clicked', () => {
75
+ it('should toggle details when button is clicked', async () => {
65
76
  const { getByRole } = render(<OptaFootballSummary {...requiredProps} />);
66
77
  const button = getByRole('button');
67
78
 
68
79
  expect(button).toHaveTextContent('Show Details');
69
- fireEvent.click(button);
70
- expect(button).toHaveTextContent('Hide Details');
71
- fireEvent.click(button);
72
- 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
+ });
73
182
  });
74
183
  });
@@ -7,17 +7,16 @@ exports[`OptaFootballSummary should render correctly 1`] = `
7
7
  >
8
8
  <div
9
9
  class="sc-htpNat sc-bxivhb hNtyxM"
10
- />
10
+ >
11
+ <div>
12
+ Widget
13
+ </div>
14
+ </div>
11
15
  <button
12
16
  class="sc-ifAKCX fvBTJK"
13
17
  >
14
18
  Show Details
15
19
  </button>
16
- <div
17
- class="sc-bwzfXH eSqyJ"
18
- >
19
- Placeholder
20
- </div>
21
20
  </div>
22
21
  </DocumentFragment>
23
22
  `;
@@ -13,6 +13,7 @@ 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';
16
17
 
17
18
  export const OptaRugbySummary: React.FC<{
18
19
  season: string;
@@ -33,6 +34,7 @@ export const OptaRugbySummary: React.FC<{
33
34
  heightLg = 197
34
35
  }) => {
35
36
  const ref = React.createRef<HTMLDivElement>();
37
+ const containerRef = React.createRef<HTMLDivElement>();
36
38
  const [isReady, setIsReady] = useState<boolean>(false);
37
39
  const [showDetails, setShowDetails] = useState<boolean>(false);
38
40
 
@@ -73,6 +75,16 @@ export const OptaRugbySummary: React.FC<{
73
75
  });
74
76
  }, []);
75
77
 
78
+ useEffect(
79
+ () => {
80
+ const height = containerRef.current
81
+ ? containerRef.current.offsetHeight
82
+ : 0;
83
+ emitEvent('updateHeight', height);
84
+ },
85
+ [showDetails]
86
+ );
87
+
76
88
  return (
77
89
  <Container
78
90
  fullWidth={full_width}
@@ -80,6 +92,7 @@ export const OptaRugbySummary: React.FC<{
80
92
  heightMd={heightMd}
81
93
  heightLg={heightLg}
82
94
  hasPadding
95
+ ref={containerRef}
83
96
  >
84
97
  <WidgetContainer ref={ref} showDetails={showDetails} />
85
98