@times-components/ts-components 1.25.1 → 1.26.2
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/CHANGELOG.md +27 -0
- package/dist/__mocks__/isomorphic-unfetch.d.ts +3 -0
- package/dist/__mocks__/isomorphic-unfetch.js +4 -0
- package/dist/components/opta/football/fixtures/OptaFootballFixtures.js +5 -4
- package/dist/components/opta/football/fixtures/__tests__/OptaFootballFixtures.test.d.ts +2 -0
- package/dist/components/opta/football/fixtures/__tests__/OptaFootballFixtures.test.js +41 -0
- package/dist/components/opta/football/match-stats/OptaFootballMatchStats.js +4 -3
- package/dist/components/opta/football/match-stats/__tests__/OptaFootballMatchStats.test.d.ts +2 -0
- package/dist/components/opta/football/match-stats/__tests__/OptaFootballMatchStats.test.js +40 -0
- package/dist/components/opta/football/standings/OptaFootballStandings.js +4 -3
- package/dist/components/opta/football/standings/__tests__/OptaFootballStandings.test.d.ts +2 -0
- package/dist/components/opta/football/standings/__tests__/OptaFootballStandings.test.js +39 -0
- package/dist/components/opta/football/summary/OptaFootballSummary.js +4 -3
- package/dist/components/opta/football/summary/__tests__/OptaFootballSummary.test.d.ts +2 -0
- package/dist/components/opta/football/summary/__tests__/OptaFootballSummary.test.js +40 -0
- package/dist/components/opta/rugby/fixtures/OptaRugbyFixtures.d.ts +8 -0
- package/dist/components/opta/rugby/fixtures/OptaRugbyFixtures.js +54 -0
- package/dist/components/opta/rugby/fixtures/OptaRugbyFixtures.stories.d.ts +1 -0
- package/dist/components/opta/rugby/fixtures/OptaRugbyFixtures.stories.js +26 -0
- package/dist/components/opta/rugby/fixtures/__tests__/OptaRugbyFixtures.test.d.ts +2 -0
- package/dist/components/opta/rugby/fixtures/__tests__/OptaRugbyFixtures.test.js +41 -0
- package/dist/components/opta/rugby/fixtures/styles.d.ts +2 -0
- package/dist/components/opta/rugby/fixtures/styles.js +255 -0
- package/dist/components/opta/rugby/match-stats/OptaRugbyMatchStats.d.ts +7 -0
- package/dist/components/opta/rugby/match-stats/OptaRugbyMatchStats.js +43 -0
- package/dist/components/opta/rugby/match-stats/OptaRugbyMatchStats.stories.d.ts +1 -0
- package/dist/components/opta/rugby/match-stats/OptaRugbyMatchStats.stories.js +26 -0
- package/dist/components/opta/rugby/match-stats/__tests__/OptaRugbyMatchStats.test.d.ts +2 -0
- package/dist/components/opta/rugby/match-stats/__tests__/OptaRugbyMatchStats.test.js +40 -0
- package/dist/components/opta/rugby/match-stats/styles.d.ts +1 -0
- package/dist/components/opta/rugby/match-stats/styles.js +153 -0
- package/dist/components/opta/rugby/shared-styles.d.ts +6 -0
- package/dist/components/opta/rugby/shared-styles.js +72 -0
- package/dist/components/opta/rugby/standings/OptaRugbyStandings.d.ts +8 -0
- package/dist/components/opta/rugby/standings/OptaRugbyStandings.js +36 -0
- package/dist/components/opta/rugby/standings/OptaRugbyStandings.stories.d.ts +1 -0
- package/dist/components/opta/rugby/standings/OptaRugbyStandings.stories.js +36 -0
- package/dist/components/opta/rugby/standings/__tests__/OptaRugbyStandings.test.d.ts +2 -0
- package/dist/components/opta/rugby/standings/__tests__/OptaRugbyStandings.test.js +39 -0
- package/dist/components/opta/rugby/standings/styles.d.ts +1 -0
- package/dist/components/opta/rugby/standings/styles.js +247 -0
- package/dist/components/opta/rugby/summary/OptaRugbySummary.d.ts +7 -0
- package/dist/components/opta/rugby/summary/OptaRugbySummary.js +44 -0
- package/dist/components/opta/rugby/summary/OptaRugbySummary.stories.d.ts +1 -0
- package/dist/components/opta/rugby/summary/OptaRugbySummary.stories.js +26 -0
- package/dist/components/opta/rugby/summary/__tests__/OptaRugbySummary.test.d.ts +2 -0
- package/dist/components/opta/rugby/summary/__tests__/OptaRugbySummary.test.js +40 -0
- package/dist/components/opta/rugby/summary/styles.d.ts +1 -0
- package/dist/components/opta/rugby/summary/styles.js +152 -0
- package/dist/components/opta/utils/__tests__/config.test.d.ts +1 -0
- package/dist/components/opta/utils/__tests__/config.test.js +24 -0
- package/dist/components/opta/utils/config.d.ts +1 -1
- package/dist/components/opta/utils/config.js +12 -3
- package/dist/helpers/fetch/FetchProvider.js +3 -3
- package/dist/helpers/fetch/__tests__/FetchProvider.test.d.ts +0 -1
- package/dist/helpers/fetch/__tests__/FetchProvider.test.js +17 -23
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -1
- package/jest.config.js +4 -4
- package/package.json +6 -5
- package/rnw.js +1 -1
- package/src/__mocks__/isomorphic-unfetch.ts +3 -0
- package/src/components/opta/football/fixtures/OptaFootballFixtures.tsx +5 -3
- package/src/components/opta/football/fixtures/__tests__/OptaFootballFixtures.test.tsx +53 -0
- package/src/components/opta/football/fixtures/__tests__/__snapshots__/OptaFootballFixtures.test.tsx.snap +34 -0
- package/src/components/opta/football/match-stats/OptaFootballMatchStats.tsx +4 -2
- package/src/components/opta/football/match-stats/__tests__/OptaFootballMatchStats.test.tsx +52 -0
- package/src/components/opta/football/match-stats/__tests__/__snapshots__/OptaFootballMatchStats.test.tsx.snap +34 -0
- package/src/components/opta/football/standings/OptaFootballStandings.tsx +4 -2
- package/src/components/opta/football/standings/__tests__/OptaFootballStandings.test.tsx +51 -0
- package/src/components/opta/football/standings/__tests__/__snapshots__/OptaFootballStandings.test.tsx.snap +34 -0
- package/src/components/opta/football/summary/OptaFootballSummary.tsx +4 -2
- package/src/components/opta/football/summary/__tests__/OptaFootballSummary.test.tsx +52 -0
- package/src/components/opta/football/summary/__tests__/__snapshots__/OptaFootballSummary.test.tsx.snap +34 -0
- package/src/components/opta/rugby/fixtures/OptaRugbyFixtures.stories.tsx +44 -0
- package/src/components/opta/rugby/fixtures/OptaRugbyFixtures.tsx +86 -0
- package/src/components/opta/rugby/fixtures/__tests__/OptaRugbyFixtures.test.tsx +53 -0
- package/src/components/opta/rugby/fixtures/__tests__/__snapshots__/OptaRugbyFixtures.test.tsx.snap +34 -0
- package/src/components/opta/rugby/fixtures/styles.ts +257 -0
- package/src/components/opta/rugby/match-stats/OptaRugbyMatchStats.stories.tsx +34 -0
- package/src/components/opta/rugby/match-stats/OptaRugbyMatchStats.tsx +71 -0
- package/src/components/opta/rugby/match-stats/__tests__/OptaRugbyMatchStats.test.tsx +52 -0
- package/src/components/opta/rugby/match-stats/__tests__/__snapshots__/OptaRugbyMatchStats.test.tsx.snap +34 -0
- package/src/components/opta/rugby/match-stats/styles.ts +154 -0
- package/src/components/opta/rugby/shared-styles.ts +75 -0
- package/src/components/opta/rugby/standings/OptaRugbyStandings.stories.tsx +49 -0
- package/src/components/opta/rugby/standings/OptaRugbyStandings.tsx +66 -0
- package/src/components/opta/rugby/standings/__tests__/OptaRugbyStandings.test.tsx +51 -0
- package/src/components/opta/rugby/standings/__tests__/__snapshots__/OptaRugbyStandings.test.tsx.snap +34 -0
- package/src/components/opta/rugby/standings/styles.ts +248 -0
- package/src/components/opta/rugby/summary/OptaRugbySummary.stories.tsx +34 -0
- package/src/components/opta/rugby/summary/OptaRugbySummary.tsx +71 -0
- package/src/components/opta/rugby/summary/__tests__/OptaRugbySummary.test.tsx +52 -0
- package/src/components/opta/rugby/summary/__tests__/__snapshots__/OptaRugbySummary.test.tsx.snap +34 -0
- package/src/components/opta/rugby/summary/styles.ts +153 -0
- package/src/components/opta/utils/__tests__/config.test.tsx +38 -0
- package/src/components/opta/utils/config.ts +13 -3
- package/src/helpers/fetch/FetchProvider.tsx +2 -2
- package/src/helpers/fetch/__tests__/FetchProvider.test.tsx +21 -31
- package/src/helpers/fetch/__tests__/__snapshots__/FetchProvider.test.tsx.snap +10 -2
- package/src/index.ts +14 -0
|
@@ -25,15 +25,17 @@ export const OptaFootballFixtures: React.FC<{
|
|
|
25
25
|
const [isReady, setIsReady] = useState<boolean>(false);
|
|
26
26
|
|
|
27
27
|
useEffect(() => {
|
|
28
|
+
const sport = 'football';
|
|
29
|
+
|
|
28
30
|
initSettings();
|
|
29
|
-
initStyleSheet();
|
|
31
|
+
initStyleSheet(sport);
|
|
30
32
|
|
|
31
33
|
initScript().then(() => {
|
|
32
34
|
if (ref.current) {
|
|
33
35
|
ref.current.innerHTML = initElement(
|
|
34
36
|
'opta-widget',
|
|
35
37
|
{
|
|
36
|
-
sport
|
|
38
|
+
sport,
|
|
37
39
|
widget: 'fixtures',
|
|
38
40
|
season,
|
|
39
41
|
competition,
|
|
@@ -47,7 +49,7 @@ export const OptaFootballFixtures: React.FC<{
|
|
|
47
49
|
breakpoints: 520
|
|
48
50
|
},
|
|
49
51
|
initElement('opta-widget', {
|
|
50
|
-
sport
|
|
52
|
+
sport,
|
|
51
53
|
widget: 'match_summary',
|
|
52
54
|
season: '',
|
|
53
55
|
competition: '',
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitForElementToBeRemoved } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import 'regenerator-runtime';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
7
|
+
jest.mock('@times-components/image', () => ({
|
|
8
|
+
Placeholder: () => <>Placeholder</>
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
const mockInitSettings = jest.fn();
|
|
12
|
+
const mockInitStyleSheet = jest.fn();
|
|
13
|
+
const mockInitComponent = jest.fn();
|
|
14
|
+
|
|
15
|
+
const mockInitElement = () => {
|
|
16
|
+
const element = document.createElement('div');
|
|
17
|
+
element.appendChild(document.createTextNode('Widget'));
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
jest.mock('../../../utils/config', () => ({
|
|
22
|
+
initSettings: mockInitSettings,
|
|
23
|
+
initStyleSheet: mockInitStyleSheet,
|
|
24
|
+
initScript: () => new Promise(resolve => resolve({})),
|
|
25
|
+
initElement: mockInitElement,
|
|
26
|
+
initComponent: mockInitComponent
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
import { OptaFootballFixtures } from '../OptaFootballFixtures';
|
|
30
|
+
|
|
31
|
+
const requiredProps = {
|
|
32
|
+
season: '2020',
|
|
33
|
+
competition: '3',
|
|
34
|
+
date_from: '2021-06-20',
|
|
35
|
+
date_to: '2021-07-11'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
describe('OptaFootballFixtures', () => {
|
|
39
|
+
it('should render correctly', async () => {
|
|
40
|
+
const { asFragment, getByText } = render(
|
|
41
|
+
<OptaFootballFixtures {...requiredProps} />
|
|
42
|
+
);
|
|
43
|
+
expect(asFragment()).toMatchSnapshot();
|
|
44
|
+
|
|
45
|
+
await waitForElementToBeRemoved(getByText('Placeholder'));
|
|
46
|
+
|
|
47
|
+
expect(mockInitSettings).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(mockInitComponent).toHaveBeenCalledTimes(1);
|
|
50
|
+
|
|
51
|
+
expect(asFragment()).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`OptaFootballFixtures should render correctly 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="sc-bdVaJa giUBsz"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="sc-htpNat sc-ifAKCX ceXVkP"
|
|
10
|
+
/>
|
|
11
|
+
<div
|
|
12
|
+
class="sc-bwzfXH kVYHKf"
|
|
13
|
+
>
|
|
14
|
+
Placeholder
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</DocumentFragment>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`OptaFootballFixtures should render correctly 2`] = `
|
|
21
|
+
<DocumentFragment>
|
|
22
|
+
<div
|
|
23
|
+
class="sc-bdVaJa hGXeaj"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="sc-htpNat sc-ifAKCX ceXVkP"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Widget
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|
|
@@ -24,13 +24,15 @@ export const OptaFootballMatchStats: React.FC<{
|
|
|
24
24
|
const [isReady, setIsReady] = useState<boolean>(false);
|
|
25
25
|
|
|
26
26
|
useEffect(() => {
|
|
27
|
+
const sport = 'football';
|
|
28
|
+
|
|
27
29
|
initSettings();
|
|
28
|
-
initStyleSheet();
|
|
30
|
+
initStyleSheet(sport);
|
|
29
31
|
|
|
30
32
|
initScript().then(() => {
|
|
31
33
|
if (ref.current) {
|
|
32
34
|
ref.current.innerHTML = initElement('opta-widget', {
|
|
33
|
-
sport
|
|
35
|
+
sport,
|
|
34
36
|
widget: 'matchstats',
|
|
35
37
|
season,
|
|
36
38
|
competition,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitForElementToBeRemoved } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import 'regenerator-runtime';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
7
|
+
jest.mock('@times-components/image', () => ({
|
|
8
|
+
Placeholder: () => <>Placeholder</>
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
const mockInitSettings = jest.fn();
|
|
12
|
+
const mockInitStyleSheet = jest.fn();
|
|
13
|
+
const mockInitComponent = jest.fn();
|
|
14
|
+
|
|
15
|
+
const mockInitElement = () => {
|
|
16
|
+
const element = document.createElement('div');
|
|
17
|
+
element.appendChild(document.createTextNode('Widget'));
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
jest.mock('../../../utils/config', () => ({
|
|
22
|
+
initSettings: mockInitSettings,
|
|
23
|
+
initStyleSheet: mockInitStyleSheet,
|
|
24
|
+
initScript: () => new Promise(resolve => resolve({})),
|
|
25
|
+
initElement: mockInitElement,
|
|
26
|
+
initComponent: mockInitComponent
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
import { OptaFootballMatchStats } from '../OptaFootballMatchStats';
|
|
30
|
+
|
|
31
|
+
const requiredProps = {
|
|
32
|
+
season: '2020',
|
|
33
|
+
competition: '3',
|
|
34
|
+
match: '2041900'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe('OptaFootballMatchStats', () => {
|
|
38
|
+
it('should render correctly', async () => {
|
|
39
|
+
const { asFragment, getByText } = render(
|
|
40
|
+
<OptaFootballMatchStats {...requiredProps} />
|
|
41
|
+
);
|
|
42
|
+
expect(asFragment()).toMatchSnapshot();
|
|
43
|
+
|
|
44
|
+
await waitForElementToBeRemoved(getByText('Placeholder'));
|
|
45
|
+
|
|
46
|
+
expect(mockInitSettings).toHaveBeenCalledTimes(1);
|
|
47
|
+
expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(mockInitComponent).toHaveBeenCalledTimes(1);
|
|
49
|
+
|
|
50
|
+
expect(asFragment()).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`OptaFootballMatchStats should render correctly 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="sc-bdVaJa giUBsz"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="sc-htpNat sc-bxivhb ljTAFU"
|
|
10
|
+
/>
|
|
11
|
+
<div
|
|
12
|
+
class="sc-bwzfXH kVYHKf"
|
|
13
|
+
>
|
|
14
|
+
Placeholder
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</DocumentFragment>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`OptaFootballMatchStats should render correctly 2`] = `
|
|
21
|
+
<DocumentFragment>
|
|
22
|
+
<div
|
|
23
|
+
class="sc-bdVaJa hGXeaj"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="sc-htpNat sc-bxivhb ljTAFU"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Widget
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|
|
@@ -26,13 +26,15 @@ export const OptaFootballStandings: React.FC<{
|
|
|
26
26
|
const [isReady, setIsReady] = useState<boolean>(false);
|
|
27
27
|
|
|
28
28
|
useEffect(() => {
|
|
29
|
+
const sport = 'football';
|
|
30
|
+
|
|
29
31
|
initSettings();
|
|
30
|
-
initStyleSheet();
|
|
32
|
+
initStyleSheet(sport);
|
|
31
33
|
|
|
32
34
|
initScript().then(() => {
|
|
33
35
|
if (ref.current) {
|
|
34
36
|
ref.current.innerHTML = initElement('opta-widget', {
|
|
35
|
-
sport
|
|
37
|
+
sport,
|
|
36
38
|
widget: 'standings',
|
|
37
39
|
season,
|
|
38
40
|
competition,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitForElementToBeRemoved } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import 'regenerator-runtime';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
7
|
+
jest.mock('@times-components/image', () => ({
|
|
8
|
+
Placeholder: () => <>Placeholder</>
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
const mockInitSettings = jest.fn();
|
|
12
|
+
const mockInitStyleSheet = jest.fn();
|
|
13
|
+
const mockInitComponent = jest.fn();
|
|
14
|
+
|
|
15
|
+
const mockInitElement = () => {
|
|
16
|
+
const element = document.createElement('div');
|
|
17
|
+
element.appendChild(document.createTextNode('Widget'));
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
jest.mock('../../../utils/config', () => ({
|
|
22
|
+
initSettings: mockInitSettings,
|
|
23
|
+
initStyleSheet: mockInitStyleSheet,
|
|
24
|
+
initScript: () => new Promise(resolve => resolve({})),
|
|
25
|
+
initElement: mockInitElement,
|
|
26
|
+
initComponent: mockInitComponent
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
import { OptaFootballStandings } from '../OptaFootballStandings';
|
|
30
|
+
|
|
31
|
+
const requiredProps = {
|
|
32
|
+
season: '2020',
|
|
33
|
+
competition: '3'
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe('OptaFootballStandings', () => {
|
|
37
|
+
it('should render correctly', async () => {
|
|
38
|
+
const { asFragment, getByText } = render(
|
|
39
|
+
<OptaFootballStandings {...requiredProps} />
|
|
40
|
+
);
|
|
41
|
+
expect(asFragment()).toMatchSnapshot();
|
|
42
|
+
|
|
43
|
+
await waitForElementToBeRemoved(getByText('Placeholder'));
|
|
44
|
+
|
|
45
|
+
expect(mockInitSettings).toHaveBeenCalledTimes(1);
|
|
46
|
+
expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
|
|
47
|
+
expect(mockInitComponent).toHaveBeenCalledTimes(1);
|
|
48
|
+
|
|
49
|
+
expect(asFragment()).toMatchSnapshot();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`OptaFootballStandings should render correctly 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="sc-bdVaJa giUBsz"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="sc-htpNat sc-bxivhb cPAtKK"
|
|
10
|
+
/>
|
|
11
|
+
<div
|
|
12
|
+
class="sc-bwzfXH kVYHKf"
|
|
13
|
+
>
|
|
14
|
+
Placeholder
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</DocumentFragment>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`OptaFootballStandings should render correctly 2`] = `
|
|
21
|
+
<DocumentFragment>
|
|
22
|
+
<div
|
|
23
|
+
class="sc-bdVaJa hGXeaj"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="sc-htpNat sc-bxivhb cPAtKK"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Widget
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|
|
@@ -24,13 +24,15 @@ export const OptaFootballSummary: React.FC<{
|
|
|
24
24
|
const [isReady, setIsReady] = useState<boolean>(false);
|
|
25
25
|
|
|
26
26
|
useEffect(() => {
|
|
27
|
+
const sport = 'football';
|
|
28
|
+
|
|
27
29
|
initSettings();
|
|
28
|
-
initStyleSheet();
|
|
30
|
+
initStyleSheet(sport);
|
|
29
31
|
|
|
30
32
|
initScript().then(() => {
|
|
31
33
|
if (ref.current) {
|
|
32
34
|
ref.current.innerHTML = initElement('opta-widget', {
|
|
33
|
-
sport
|
|
35
|
+
sport,
|
|
34
36
|
widget: 'match_summary',
|
|
35
37
|
season,
|
|
36
38
|
competition,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitForElementToBeRemoved } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import 'regenerator-runtime';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
7
|
+
jest.mock('@times-components/image', () => ({
|
|
8
|
+
Placeholder: () => <>Placeholder</>
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
const mockInitSettings = jest.fn();
|
|
12
|
+
const mockInitStyleSheet = jest.fn();
|
|
13
|
+
const mockInitComponent = jest.fn();
|
|
14
|
+
|
|
15
|
+
const mockInitElement = () => {
|
|
16
|
+
const element = document.createElement('div');
|
|
17
|
+
element.appendChild(document.createTextNode('Widget'));
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
jest.mock('../../../utils/config', () => ({
|
|
22
|
+
initSettings: mockInitSettings,
|
|
23
|
+
initStyleSheet: mockInitStyleSheet,
|
|
24
|
+
initScript: () => new Promise(resolve => resolve({})),
|
|
25
|
+
initElement: mockInitElement,
|
|
26
|
+
initComponent: mockInitComponent
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
import { OptaFootballSummary } from '../OptaFootballSummary';
|
|
30
|
+
|
|
31
|
+
const requiredProps = {
|
|
32
|
+
season: '2020',
|
|
33
|
+
competition: '3',
|
|
34
|
+
match: '2041900'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe('OptaFootballSummary', () => {
|
|
38
|
+
it('should render correctly', async () => {
|
|
39
|
+
const { asFragment, getByText } = render(
|
|
40
|
+
<OptaFootballSummary {...requiredProps} />
|
|
41
|
+
);
|
|
42
|
+
expect(asFragment()).toMatchSnapshot();
|
|
43
|
+
|
|
44
|
+
await waitForElementToBeRemoved(getByText('Placeholder'));
|
|
45
|
+
|
|
46
|
+
expect(mockInitSettings).toHaveBeenCalledTimes(1);
|
|
47
|
+
expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(mockInitComponent).toHaveBeenCalledTimes(1);
|
|
49
|
+
|
|
50
|
+
expect(asFragment()).toMatchSnapshot();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`OptaFootballSummary should render correctly 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="sc-bdVaJa giUBsz"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="sc-htpNat sc-bxivhb hHhneA"
|
|
10
|
+
/>
|
|
11
|
+
<div
|
|
12
|
+
class="sc-bwzfXH kVYHKf"
|
|
13
|
+
>
|
|
14
|
+
Placeholder
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</DocumentFragment>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`OptaFootballSummary should render correctly 2`] = `
|
|
21
|
+
<DocumentFragment>
|
|
22
|
+
<div
|
|
23
|
+
class="sc-bdVaJa hGXeaj"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="sc-htpNat sc-bxivhb hHhneA"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Widget
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { showcaseConverter } from '@times-components/storybook';
|
|
3
|
+
|
|
4
|
+
import { ArticleHarness } from '../../../../fixtures/article-harness/ArticleHarness';
|
|
5
|
+
import { OptaRugbyFixtures } from './OptaRugbyFixtures';
|
|
6
|
+
|
|
7
|
+
const showcase = {
|
|
8
|
+
children: [
|
|
9
|
+
{
|
|
10
|
+
decorator: (storyFn: () => React.ReactNode) => (
|
|
11
|
+
<ArticleHarness>{storyFn()}</ArticleHarness>
|
|
12
|
+
),
|
|
13
|
+
type: 'decorator'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
component: () => (
|
|
17
|
+
<OptaRugbyFixtures
|
|
18
|
+
season="2022"
|
|
19
|
+
competition="209"
|
|
20
|
+
date_from="2022-01-01"
|
|
21
|
+
date_to="2022-12-01"
|
|
22
|
+
/>
|
|
23
|
+
),
|
|
24
|
+
name: 'Fixtures',
|
|
25
|
+
type: 'story'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
component: () => (
|
|
29
|
+
<OptaRugbyFixtures
|
|
30
|
+
season="2022"
|
|
31
|
+
competition="209"
|
|
32
|
+
date_from="2022-01-01"
|
|
33
|
+
date_to="2022-12-01"
|
|
34
|
+
/>
|
|
35
|
+
),
|
|
36
|
+
name: 'Fixtures (results)',
|
|
37
|
+
type: 'story'
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
name: 'Typescript Component/In Article/Rugby/Fixtures'
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
showcaseConverter(module, showcase);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Placeholder } from '@times-components/image';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
initSettings,
|
|
7
|
+
initStyleSheet,
|
|
8
|
+
initScript,
|
|
9
|
+
initElement,
|
|
10
|
+
initComponent
|
|
11
|
+
} from '../../utils/config';
|
|
12
|
+
|
|
13
|
+
import { Container, PlaceholderContainer } from '../shared-styles';
|
|
14
|
+
import { WidgetContainer } from './styles';
|
|
15
|
+
|
|
16
|
+
export const OptaRugbyFixtures: React.FC<{
|
|
17
|
+
season: string;
|
|
18
|
+
competition: string;
|
|
19
|
+
date_from: string;
|
|
20
|
+
date_to: string;
|
|
21
|
+
full_width?: boolean;
|
|
22
|
+
}> = React.memo(({ season, competition, date_from, date_to, full_width }) => {
|
|
23
|
+
const ref = React.createRef<HTMLDivElement>();
|
|
24
|
+
|
|
25
|
+
const [isReady, setIsReady] = useState<boolean>(false);
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const sport = 'rugby';
|
|
29
|
+
|
|
30
|
+
initSettings();
|
|
31
|
+
initStyleSheet(sport);
|
|
32
|
+
|
|
33
|
+
initScript().then(() => {
|
|
34
|
+
if (ref.current) {
|
|
35
|
+
ref.current.innerHTML = initElement(
|
|
36
|
+
'opta-widget',
|
|
37
|
+
{
|
|
38
|
+
sport,
|
|
39
|
+
widget: 'fixtures',
|
|
40
|
+
season,
|
|
41
|
+
competition,
|
|
42
|
+
date_from,
|
|
43
|
+
date_to,
|
|
44
|
+
live: true,
|
|
45
|
+
grouping: 'date',
|
|
46
|
+
show_grouping: true,
|
|
47
|
+
show_subgrouping: false,
|
|
48
|
+
show_crests: true,
|
|
49
|
+
date_format: 'dddd MMMM D YYYY',
|
|
50
|
+
breakpoints: 520
|
|
51
|
+
},
|
|
52
|
+
initElement('opta-widget', {
|
|
53
|
+
sport,
|
|
54
|
+
widget: 'match_summary',
|
|
55
|
+
season: '',
|
|
56
|
+
competition: '',
|
|
57
|
+
match: '',
|
|
58
|
+
live: true,
|
|
59
|
+
show_crests: true,
|
|
60
|
+
show_tries: true,
|
|
61
|
+
show_conversions: true,
|
|
62
|
+
show_penalties: true,
|
|
63
|
+
show_drop_goals: 'scored',
|
|
64
|
+
show_cards: 'all',
|
|
65
|
+
breakpoints: '520'
|
|
66
|
+
})
|
|
67
|
+
).outerHTML;
|
|
68
|
+
|
|
69
|
+
initComponent();
|
|
70
|
+
setIsReady(true);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}, []);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Container border={isReady} fullWidth={full_width}>
|
|
77
|
+
<WidgetContainer ref={ref} />
|
|
78
|
+
|
|
79
|
+
{!isReady && (
|
|
80
|
+
<PlaceholderContainer>
|
|
81
|
+
<Placeholder />
|
|
82
|
+
</PlaceholderContainer>
|
|
83
|
+
)}
|
|
84
|
+
</Container>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, waitForElementToBeRemoved } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import 'regenerator-runtime';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
7
|
+
jest.mock('@times-components/image', () => ({
|
|
8
|
+
Placeholder: () => <>Placeholder</>
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
const mockInitSettings = jest.fn();
|
|
12
|
+
const mockInitStyleSheet = jest.fn();
|
|
13
|
+
const mockInitComponent = jest.fn();
|
|
14
|
+
|
|
15
|
+
const mockInitElement = () => {
|
|
16
|
+
const element = document.createElement('div');
|
|
17
|
+
element.appendChild(document.createTextNode('Widget'));
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
jest.mock('../../../utils/config', () => ({
|
|
22
|
+
initSettings: mockInitSettings,
|
|
23
|
+
initStyleSheet: mockInitStyleSheet,
|
|
24
|
+
initScript: () => new Promise(resolve => resolve({})),
|
|
25
|
+
initElement: mockInitElement,
|
|
26
|
+
initComponent: mockInitComponent
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
import { OptaRugbyFixtures } from '../OptaRugbyFixtures';
|
|
30
|
+
|
|
31
|
+
const requiredProps = {
|
|
32
|
+
season: '2022',
|
|
33
|
+
competition: '209',
|
|
34
|
+
date_from: '2022-01-01',
|
|
35
|
+
date_to: '2022-12-01'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
describe('OptaRugbyFixtures', () => {
|
|
39
|
+
it('should render correctly', async () => {
|
|
40
|
+
const { asFragment, getByText } = render(
|
|
41
|
+
<OptaRugbyFixtures {...requiredProps} />
|
|
42
|
+
);
|
|
43
|
+
expect(asFragment()).toMatchSnapshot();
|
|
44
|
+
|
|
45
|
+
await waitForElementToBeRemoved(getByText('Placeholder'));
|
|
46
|
+
|
|
47
|
+
expect(mockInitSettings).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(mockInitStyleSheet).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(mockInitComponent).toHaveBeenCalledTimes(1);
|
|
50
|
+
|
|
51
|
+
expect(asFragment()).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
});
|
package/src/components/opta/rugby/fixtures/__tests__/__snapshots__/OptaRugbyFixtures.test.tsx.snap
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`OptaRugbyFixtures should render correctly 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="sc-bdVaJa giUBsz"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
class="sc-htpNat sc-ifAKCX cyWAhZ"
|
|
10
|
+
/>
|
|
11
|
+
<div
|
|
12
|
+
class="sc-bwzfXH kVYHKf"
|
|
13
|
+
>
|
|
14
|
+
Placeholder
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</DocumentFragment>
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`OptaRugbyFixtures should render correctly 2`] = `
|
|
21
|
+
<DocumentFragment>
|
|
22
|
+
<div
|
|
23
|
+
class="sc-bdVaJa hGXeaj"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="sc-htpNat sc-ifAKCX cyWAhZ"
|
|
27
|
+
>
|
|
28
|
+
<div>
|
|
29
|
+
Widget
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</DocumentFragment>
|
|
34
|
+
`;
|