@times-components/ts-components 1.145.1-76ee0965069e2a17bc1f8dcf02d24e8fefd6869a.0 → 1.145.1-82bc6796129e892c1eb22c6257c5e3809c159767.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.
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.js +57 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.js +30 -14
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.js +33 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.d.ts +1 -0
- package/dist/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.js +36 -0
- package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.js +2 -2
- package/dist/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.js +1 -1
- package/dist/components/opta/football/opta-match-stats/summary/WidgetContainer.js +13 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -4
- package/package.json +3 -3
- package/rnw.js +1 -1
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.tsx +69 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/__snapshots__/OptaMatchStatsMatchdayLive.test.tsx.snap +3 -3
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx +29 -13
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/NavigationWrapper.test.tsx +67 -0
- package/src/components/opta/football/opta-match-stats/matchday-live/styles/__tests__/WidgetContainer.test.tsx +64 -0
- package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.stories.tsx +1 -1
- package/src/components/opta/football/opta-match-stats/summary/OptaMatchStatsSummary.tsx +1 -1
- package/src/components/opta/football/opta-match-stats/summary/WidgetContainer.tsx +12 -3
- package/src/components/opta/football/opta-match-stats/summary/__tests__/__snapshots__/OptaMatchStatsSummary.test.tsx.snap +1 -1
- package/src/index.ts +3 -3
package/src/components/opta/football/opta-match-stats/matchday-live/__tests__/MobileWidget.test.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent, act } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
jest.mock('@times-components/image', () => ({
|
|
6
|
+
Placeholder: () => <>Placeholder</>
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
const mockInitSettings = jest.fn();
|
|
10
|
+
const mockInitStyleSheet = jest.fn();
|
|
11
|
+
const mockInitComponent = jest.fn();
|
|
12
|
+
|
|
13
|
+
const mockInitElement = () => {
|
|
14
|
+
const element = document.createElement('div');
|
|
15
|
+
element.appendChild(document.createTextNode('Widget'));
|
|
16
|
+
return element;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
jest.mock('../../../../utils/config', () => ({
|
|
20
|
+
initSettings: mockInitSettings,
|
|
21
|
+
initStyleSheet: mockInitStyleSheet,
|
|
22
|
+
initScript: () => Promise.resolve({}),
|
|
23
|
+
initElement: mockInitElement,
|
|
24
|
+
initComponent: mockInitComponent
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
import { MobileWidget } from '../MobileWidget';
|
|
28
|
+
|
|
29
|
+
const requiredProps = {
|
|
30
|
+
season: '2020',
|
|
31
|
+
competition: '3',
|
|
32
|
+
match: '2041900',
|
|
33
|
+
homeTeamName: 'Liverpool',
|
|
34
|
+
awayTeamName: 'Manchester City'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe('MobileWidget navigation buttons state', () => {
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
jest.clearAllMocks();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('renders with home active and toggles to away on click', async () => {
|
|
43
|
+
render(<MobileWidget {...requiredProps} />);
|
|
44
|
+
|
|
45
|
+
const homeBtn = screen.getByRole('button', { name: 'Liverpool' });
|
|
46
|
+
const awayBtn = screen.getByRole('button', { name: 'Manchester City' });
|
|
47
|
+
expect(homeBtn).toHaveClass('home');
|
|
48
|
+
expect(homeBtn).toHaveClass('active');
|
|
49
|
+
expect(awayBtn).toHaveClass('away');
|
|
50
|
+
expect(awayBtn).not.toHaveClass('active');
|
|
51
|
+
|
|
52
|
+
fireEvent.click(awayBtn);
|
|
53
|
+
expect(awayBtn).toHaveClass('active');
|
|
54
|
+
expect(homeBtn).not.toHaveClass('active');
|
|
55
|
+
|
|
56
|
+
expect(homeBtn).toHaveClass('home');
|
|
57
|
+
|
|
58
|
+
await act(async () => {
|
|
59
|
+
await Promise.resolve();
|
|
60
|
+
});
|
|
61
|
+
// Placeholder may still be present during async; assert wrapper exists
|
|
62
|
+
expect(screen.getByTestId('mobile-navigation-wrapper')).toBeInTheDocument();
|
|
63
|
+
|
|
64
|
+
fireEvent.click(homeBtn);
|
|
65
|
+
expect(homeBtn).toHaveClass('active');
|
|
66
|
+
expect(awayBtn).not.toHaveClass('active');
|
|
67
|
+
expect(awayBtn).toHaveClass('away');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -12,7 +12,7 @@ exports[`OptaMatchStatsMatchdayLive should render correctly 1`] = `
|
|
|
12
12
|
Line-ups
|
|
13
13
|
</h3>
|
|
14
14
|
<div
|
|
15
|
-
class="sc-ifAKCX
|
|
15
|
+
class="sc-ifAKCX hfZGOd"
|
|
16
16
|
/>
|
|
17
17
|
</div>
|
|
18
18
|
<div
|
|
@@ -43,10 +43,10 @@ exports[`OptaMatchStatsMatchdayLive should render correctly 1`] = `
|
|
|
43
43
|
</button>
|
|
44
44
|
</div>
|
|
45
45
|
<div
|
|
46
|
-
class="home-widget-container sc-ifAKCX
|
|
46
|
+
class="home-widget-container sc-ifAKCX hfZGOd"
|
|
47
47
|
/>
|
|
48
48
|
<div
|
|
49
|
-
class="away-widget-container sc-ifAKCX
|
|
49
|
+
class="away-widget-container sc-ifAKCX hfZGOd"
|
|
50
50
|
/>
|
|
51
51
|
<div
|
|
52
52
|
class="sc-bwzfXH eSqyJ"
|
package/src/components/opta/football/opta-match-stats/matchday-live/styles/WidgetContainer.tsx
CHANGED
|
@@ -253,9 +253,8 @@ export const WidgetContainer = styled.div<{
|
|
|
253
253
|
height: auto;
|
|
254
254
|
|
|
255
255
|
.Opta-Sub {
|
|
256
|
-
display:
|
|
257
|
-
|
|
258
|
-
grid-template-rows: auto auto;
|
|
256
|
+
display: flex;
|
|
257
|
+
align-items: center;
|
|
259
258
|
|
|
260
259
|
&.Opta-Home {
|
|
261
260
|
span.Opta-Circle {
|
|
@@ -296,14 +295,14 @@ export const WidgetContainer = styled.div<{
|
|
|
296
295
|
}
|
|
297
296
|
|
|
298
297
|
span.Opta-Circle {
|
|
299
|
-
grid-column: 1 / 1;
|
|
300
|
-
grid-row: 1 / 3;
|
|
301
298
|
background-color: ${backgroundColor};
|
|
302
299
|
font-family: ${fonts.headline};
|
|
303
300
|
font-weight: 800;
|
|
304
301
|
font-size: 16px;
|
|
305
302
|
line-height: 112.99999%;
|
|
306
303
|
margin-bottom: 0;
|
|
304
|
+
min-width: 32px;
|
|
305
|
+
margin-right: 12px;
|
|
307
306
|
|
|
308
307
|
${props =>
|
|
309
308
|
props.isApp &&
|
|
@@ -314,15 +313,12 @@ export const WidgetContainer = styled.div<{
|
|
|
314
313
|
`};
|
|
315
314
|
|
|
316
315
|
& + span.Opta-PlayerName {
|
|
317
|
-
|
|
318
|
-
grid-row: 1 / 2;
|
|
319
|
-
padding-right: 8px;
|
|
316
|
+
padding-right: 4px;
|
|
320
317
|
width: max-content;
|
|
321
318
|
font-size: 14px !important;
|
|
319
|
+
white-space: nowrap;
|
|
322
320
|
|
|
323
321
|
& + span.Opta-PlayerName {
|
|
324
|
-
grid-column: 4 / 5;
|
|
325
|
-
grid-row: 1 / 2;
|
|
326
322
|
width: max-content;
|
|
327
323
|
font-size: 14px !important;
|
|
328
324
|
}
|
|
@@ -337,10 +333,9 @@ export const WidgetContainer = styled.div<{
|
|
|
337
333
|
}
|
|
338
334
|
|
|
339
335
|
span.Opta-MatcheventsIcons {
|
|
340
|
-
grid-column: 3 / 5;
|
|
341
|
-
grid-row: 2 / 3;
|
|
342
336
|
display: flex;
|
|
343
337
|
gap: 4px;
|
|
338
|
+
margin-top: 0;
|
|
344
339
|
}
|
|
345
340
|
}
|
|
346
341
|
}
|
|
@@ -428,6 +423,7 @@ export const WidgetContainer = styled.div<{
|
|
|
428
423
|
grid-template-rows: 1fr;
|
|
429
424
|
padding-inline: 32px;
|
|
430
425
|
padding-block: 32px;
|
|
426
|
+
padding-bottom: 16px;
|
|
431
427
|
${props =>
|
|
432
428
|
props.isApp &&
|
|
433
429
|
`
|
|
@@ -463,7 +459,7 @@ export const WidgetContainer = styled.div<{
|
|
|
463
459
|
color: ${textColor} !important;
|
|
464
460
|
font-family: ${fonts.headline} !important;
|
|
465
461
|
font-weight: 800;
|
|
466
|
-
font-size:
|
|
462
|
+
font-size: 28px;
|
|
467
463
|
line-height: 112.999%;
|
|
468
464
|
padding-bottom: 4px;
|
|
469
465
|
}
|
|
@@ -475,6 +471,26 @@ export const WidgetContainer = styled.div<{
|
|
|
475
471
|
line-height: 112.999%;
|
|
476
472
|
}
|
|
477
473
|
}
|
|
474
|
+
|
|
475
|
+
.Opta-Close {
|
|
476
|
+
background: none !important;
|
|
477
|
+
top: 16px !important;
|
|
478
|
+
right: 16px !important;
|
|
479
|
+
position: relative;
|
|
480
|
+
&::before {
|
|
481
|
+
position: absolute;
|
|
482
|
+
top: 0;
|
|
483
|
+
left: 0;
|
|
484
|
+
right: 0;
|
|
485
|
+
bottom: 0;
|
|
486
|
+
display: flex;
|
|
487
|
+
justify-content: center;
|
|
488
|
+
align-items: center;
|
|
489
|
+
content: '\\00D7';
|
|
490
|
+
font-size: 32px;
|
|
491
|
+
color: ${textColor};
|
|
492
|
+
}
|
|
493
|
+
}
|
|
478
494
|
}
|
|
479
495
|
|
|
480
496
|
// Mobile styles
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { NavigationWrapper } from '../NavigationWrapper';
|
|
5
|
+
|
|
6
|
+
const HomeColour = { light: '#123456', dark: '#abcdef' };
|
|
7
|
+
const AwayColour = { light: '#654321', dark: '#fedcba' };
|
|
8
|
+
|
|
9
|
+
describe('Matchday Live NavigationWrapper', () => {
|
|
10
|
+
it('renders with active home', () => {
|
|
11
|
+
const { container } = render(
|
|
12
|
+
<NavigationWrapper
|
|
13
|
+
isApp={false}
|
|
14
|
+
activeTeam="home"
|
|
15
|
+
homeTeamColor={HomeColour}
|
|
16
|
+
awayTeamColor={AwayColour}
|
|
17
|
+
>
|
|
18
|
+
<div className="navigation-buttons">
|
|
19
|
+
<button className="active home">Home</button>
|
|
20
|
+
<button className="away">Away</button>
|
|
21
|
+
</div>
|
|
22
|
+
<div className="home-widget-container">Home widget</div>
|
|
23
|
+
<div className="away-widget-container">Away widget</div>
|
|
24
|
+
</NavigationWrapper>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
expect(container.querySelector('.navigation-buttons')).toBeInTheDocument();
|
|
28
|
+
expect(
|
|
29
|
+
container.querySelector('.navigation-buttons .active.home')
|
|
30
|
+
).toBeInTheDocument();
|
|
31
|
+
expect(
|
|
32
|
+
container.querySelector('.home-widget-container')
|
|
33
|
+
).toBeInTheDocument();
|
|
34
|
+
expect(
|
|
35
|
+
container.querySelector('.away-widget-container')
|
|
36
|
+
).toBeInTheDocument();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('renders with active away and isApp true', () => {
|
|
40
|
+
const { container } = render(
|
|
41
|
+
<NavigationWrapper
|
|
42
|
+
isApp={true}
|
|
43
|
+
activeTeam="away"
|
|
44
|
+
homeTeamColor={HomeColour}
|
|
45
|
+
awayTeamColor={AwayColour}
|
|
46
|
+
>
|
|
47
|
+
<div className="navigation-buttons">
|
|
48
|
+
<button className="home">Home</button>
|
|
49
|
+
<button className="active away">Away</button>
|
|
50
|
+
</div>
|
|
51
|
+
<div className="home-widget-container">Home widget</div>
|
|
52
|
+
<div className="away-widget-container">Away widget</div>
|
|
53
|
+
</NavigationWrapper>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expect(container.querySelector('.navigation-buttons')).toBeInTheDocument();
|
|
57
|
+
expect(
|
|
58
|
+
container.querySelector('.navigation-buttons .active.away')
|
|
59
|
+
).toBeInTheDocument();
|
|
60
|
+
expect(
|
|
61
|
+
container.querySelector('.home-widget-container')
|
|
62
|
+
).toBeInTheDocument();
|
|
63
|
+
expect(
|
|
64
|
+
container.querySelector('.away-widget-container')
|
|
65
|
+
).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { WidgetContainer } from '../WidgetContainer';
|
|
5
|
+
|
|
6
|
+
describe('Matchday Live WidgetContainer', () => {
|
|
7
|
+
const baseProps = {
|
|
8
|
+
isApp: true,
|
|
9
|
+
homeTeamColor: { light: '#000000', dark: '#a19c9cff' },
|
|
10
|
+
awayTeamColor: { light: '#007A3F', dark: '#007A3F' }
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
it('generates styles', () => {
|
|
14
|
+
const { container } = render(
|
|
15
|
+
<WidgetContainer {...baseProps}>
|
|
16
|
+
<div className="Opta">
|
|
17
|
+
<div className="Opta_W">content</div>
|
|
18
|
+
</div>
|
|
19
|
+
</WidgetContainer>
|
|
20
|
+
);
|
|
21
|
+
expect(container.querySelector('.Opta > .Opta_W')).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('generates dark-mode styles under .Opta-Overlay .Opta-Flex', () => {
|
|
25
|
+
const { container } = render(
|
|
26
|
+
<WidgetContainer {...baseProps}>
|
|
27
|
+
<div className="Opta-Overlay">
|
|
28
|
+
<div className="Opta-Flex">flex</div>
|
|
29
|
+
</div>
|
|
30
|
+
</WidgetContainer>
|
|
31
|
+
);
|
|
32
|
+
expect(container.querySelector('.Opta-Overlay .Opta-Flex')).toBeTruthy();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('applies home-widget-container styles', () => {
|
|
36
|
+
const { container } = render(
|
|
37
|
+
<WidgetContainer {...baseProps} className="home-widget-container">
|
|
38
|
+
<div className="Opta-MatchHeader">
|
|
39
|
+
<div className="Opta-Away">Away Team</div>
|
|
40
|
+
</div>
|
|
41
|
+
</WidgetContainer>
|
|
42
|
+
);
|
|
43
|
+
expect(
|
|
44
|
+
container.querySelector(
|
|
45
|
+
'.home-widget-container .Opta-MatchHeader .Opta-Away'
|
|
46
|
+
)
|
|
47
|
+
).toBeTruthy();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('applies away-widget-container styles', () => {
|
|
51
|
+
const { container } = render(
|
|
52
|
+
<WidgetContainer {...baseProps} className="away-widget-container">
|
|
53
|
+
<div className="Opta-MatchHeader">
|
|
54
|
+
<div className="Opta-Home">Home Team</div>
|
|
55
|
+
</div>
|
|
56
|
+
</WidgetContainer>
|
|
57
|
+
);
|
|
58
|
+
expect(
|
|
59
|
+
container.querySelector(
|
|
60
|
+
'.away-widget-container .Opta-MatchHeader .Opta-Home'
|
|
61
|
+
)
|
|
62
|
+
).toBeTruthy();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -316,14 +316,23 @@ export const WidgetContainer = styled.div<{
|
|
|
316
316
|
display: flex;
|
|
317
317
|
text-align: right;
|
|
318
318
|
}
|
|
319
|
+
|
|
320
|
+
&.Opta-Home {
|
|
321
|
+
.Opta-Event-Player {
|
|
322
|
+
text-align: left;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
&.Opta-Away {
|
|
327
|
+
.Opta-Event-Player {
|
|
328
|
+
text-align: right;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
319
331
|
}
|
|
320
332
|
|
|
321
333
|
.Opta-Event-Text {
|
|
322
334
|
display: flex;
|
|
323
335
|
align-items: center;
|
|
324
|
-
.Opta-Event-Player {
|
|
325
|
-
text-align: left;
|
|
326
|
-
}
|
|
327
336
|
|
|
328
337
|
&.Opta-Home {
|
|
329
338
|
li {
|
package/src/index.ts
CHANGED
|
@@ -152,6 +152,6 @@ export {
|
|
|
152
152
|
export {
|
|
153
153
|
OptaMatchStatsCommentary
|
|
154
154
|
} from './components/opta/football/opta-match-stats/commentary/OptaMatchStatsCommentary';
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
export {
|
|
156
|
+
OptaMatchStatsMatchdayLive
|
|
157
|
+
} from './components/opta/football/opta-match-stats/matchday-live/OptaMatchStatsMatchdayLive';
|