gatsby-core-theme 2.2.4 → 4.0.0
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 +125 -0
- package/__mocks__/gatsby.js +16 -4
- package/gatsby-node.esm.js +14 -16
- package/jest.config.js +8 -1
- package/package.json +1 -1
- package/src/components/app.js +1 -17
- package/src/components/atoms/author/author.test.js +12 -5
- package/src/components/atoms/author-box/index.js +6 -5
- package/src/components/atoms/breadcrumbs/breadcrumbs.test.js +8 -0
- package/src/components/atoms/carousel/pagination-item/pagination-item.test.js +18 -3
- package/src/components/atoms/collapse/collapse.test.js +10 -0
- package/src/components/atoms/collapse/index.js +3 -1
- package/src/components/atoms/content-box/content-box.test.js +9 -6
- package/src/components/atoms/content-box/index.js +13 -12
- package/src/components/atoms/custom-select/index.js +31 -30
- package/src/components/atoms/disclaimer/disclaimer.test.js +16 -1
- package/src/components/atoms/iframe/iframe.module.scss +3 -0
- package/src/components/atoms/iframe/iframe.test.js +6 -0
- package/src/components/atoms/iframe/index.js +1 -1
- package/src/components/atoms/image/image.test.js +19 -6
- package/src/components/atoms/image/index.js +2 -4
- package/src/components/atoms/info-grid/index.js +10 -12
- package/src/components/atoms/label/index.js +2 -2
- package/src/components/atoms/label/label.test.js +4 -0
- package/src/components/atoms/menu/items/item/item.module.scss +4 -0
- package/src/components/atoms/module-title/index.js +9 -9
- package/src/components/atoms/module-title/module-title.test.js +76 -0
- package/src/components/atoms/open-graph/open-graph.test.js +34 -5
- package/src/components/atoms/operator-cta/operator-cta.test.js +26 -3
- package/src/components/atoms/scroll-to-top/scroll-to-top.test.js +6 -0
- package/src/components/atoms/search/autocomplete/operator.js +1 -1
- package/src/components/atoms/sitemap/index.js +1 -1
- package/src/components/atoms/spotlights/index.js +55 -53
- package/src/components/atoms/spotlights/spotlights.module.scss +25 -37
- package/src/components/atoms/spotlights/spotlights.test.js +13 -15
- package/src/components/molecules/content/content.test.js +127 -0
- package/src/components/molecules/content/index.js +2 -2
- package/src/components/molecules/header/header.test.js +6 -0
- package/src/components/molecules/main/main.test.js +48 -12
- package/src/components/molecules/menu/menu.test.js +27 -0
- package/src/components/molecules/module/module.test.js +134 -0
- package/src/components/molecules/operator-banner/operator-banner.test.js +7 -1
- package/src/components/molecules/pagination/pagination-with-midpoints.module.scss +48 -49
- package/src/components/organisms/anchor/index.js +1 -1
- package/src/components/organisms/cookie-consent/cookie-consent.test.js +7 -1
- package/src/components/organisms/form/form.test.js +21 -0
- package/src/components/organisms/form/index.js +5 -1
- package/src/components/organisms/navigation/index.js +9 -1
- package/src/components/organisms/search/index.js +0 -1
- package/src/components/organisms/toplist/list/index.js +1 -1
- package/src/components/organisms/toplist/list/list.test.js +30 -0
- package/src/components/pages/body/index.js +22 -5
- package/src/components/pages/tracker/index.js +1 -1
- package/src/constants/settings.js +1 -1
- package/src/helpers/getters.js +1 -6
- package/src/helpers/getters.test.js +1 -3
- package/src/helpers/processor/common.test.js +7 -1
- package/src/helpers/processor/index.js +2 -3
- package/src/helpers/processor/index.test.js +21 -0
- package/src/helpers/schema.js +30 -3
- package/src/helpers/schema.test.js +19 -10
- package/src/helpers/strings.js +10 -0
- package/src/helpers/strings.test.js +8 -0
- package/src/hooks/gatsby-img/index.js +1 -1
- package/src/hooks/lazy-image/index.js +1 -1
- package/src/hooks/lazy-image/lazy-image.test.js +39 -0
- package/src/hooks/lazy-picture/index.js +1 -1
- package/src/hooks/link/link.test.js +42 -1
- package/src/hooks/tabs/tab/tab.test.js +41 -0
- package/src/styles/utils/variables/_main.scss +3 -1
- package/tests/envVars.js +1 -1
- package/tests/factories/modules/content.factory.js +6 -3
- package/tests/factories/modules/modules.factory.js +152 -0
- package/tests/factories/modules/schema.factory.js +87 -0
- package/tests/factories/pages/list.factory.js +2 -1
- package/tests/factories/pages/pages.factory.js +192 -0
- package/tests/factories/sections/header.factory.js +8 -2
- package/src/components/atoms/logo/index.js +0 -36
- package/src/components/atoms/logo/logo.module.scss +0 -4
- package/src/components/atoms/logo/logo.stories.js +0 -57
- package/src/components/atoms/logo/logo.test.js +0 -30
- package/src/components/molecules/section/index.js +0 -24
- package/src/components/molecules/section/section.test.js +0 -16
- package/src/components/molecules/sidebar/index.js +0 -25
- package/src/components/molecules/sidebar/sidebar.module.scss +0 -3
- package/src/components/molecules/sidebar/sidebar.test.js +0 -30
|
@@ -29,10 +29,13 @@ describe('Form Component', () => {
|
|
|
29
29
|
test('on change', async () => {
|
|
30
30
|
render(<Form hasButton type="contact" submitUrl="https://submit-form.com" />);
|
|
31
31
|
const input = document.querySelector('input[type="text"]');
|
|
32
|
+
const messageInput = document.querySelector('textarea');
|
|
32
33
|
|
|
33
34
|
await waitFor(() => {
|
|
34
35
|
fireEvent.change(input, { target: { value: 'Mohsen' } });
|
|
36
|
+
fireEvent.change(messageInput, { target: { value: 'EKKK' } });
|
|
35
37
|
expect(input.value).toBe('Mohsen');
|
|
38
|
+
expect(messageInput.value).toBe('EKKK');
|
|
36
39
|
}, 3000);
|
|
37
40
|
});
|
|
38
41
|
|
|
@@ -52,6 +55,24 @@ describe('Form Component', () => {
|
|
|
52
55
|
});
|
|
53
56
|
expect(ApiCall).toHaveBeenCalled();
|
|
54
57
|
});
|
|
58
|
+
|
|
59
|
+
test('handle submit with filled fields', async () => {
|
|
60
|
+
const { container } = render(
|
|
61
|
+
<Form hasButton disabled={false} type="newsletter" submitUrl="https://submit-form.com" />
|
|
62
|
+
);
|
|
63
|
+
const nameInput = document.querySelector('input[type="text"]');
|
|
64
|
+
const emailInput = document.querySelector('input[type="email"]');
|
|
65
|
+
|
|
66
|
+
await waitFor(() => {
|
|
67
|
+
fireEvent.change(nameInput, { target: { value: 'Val' } });
|
|
68
|
+
fireEvent.change(emailInput, { target: { value: 'ejk@sl.com' } });
|
|
69
|
+
|
|
70
|
+
expect(nameInput.value).toBe('Val');
|
|
71
|
+
}, 3000);
|
|
72
|
+
|
|
73
|
+
const formElement = container.querySelector('form');
|
|
74
|
+
fireEvent.submit(formElement);
|
|
75
|
+
});
|
|
55
76
|
});
|
|
56
77
|
afterEach(() => {
|
|
57
78
|
cleanup();
|
|
@@ -12,6 +12,7 @@ const FormComponent = ({
|
|
|
12
12
|
submitUrl = '',
|
|
13
13
|
hasButton = true,
|
|
14
14
|
buttonLabel = 'Submit',
|
|
15
|
+
disabled = true,
|
|
15
16
|
}) => {
|
|
16
17
|
const recaptchaRef = useRef();
|
|
17
18
|
const [state, setState] = useState({
|
|
@@ -19,7 +20,7 @@ const FormComponent = ({
|
|
|
19
20
|
success: false,
|
|
20
21
|
failed: false,
|
|
21
22
|
isValid: true,
|
|
22
|
-
isDisabled:
|
|
23
|
+
isDisabled: disabled,
|
|
23
24
|
name: '',
|
|
24
25
|
email: '',
|
|
25
26
|
message: '',
|
|
@@ -43,7 +44,9 @@ const FormComponent = ({
|
|
|
43
44
|
}
|
|
44
45
|
const handleSubmit = (e) => {
|
|
45
46
|
e.preventDefault();
|
|
47
|
+
|
|
46
48
|
const { name, email, message, isDisabled } = state;
|
|
49
|
+
|
|
47
50
|
if (
|
|
48
51
|
name === '' ||
|
|
49
52
|
email === '' ||
|
|
@@ -171,5 +174,6 @@ FormComponent.propTypes = {
|
|
|
171
174
|
submitUrl: PropTypes.string.isRequired,
|
|
172
175
|
hasButton: PropTypes.bool,
|
|
173
176
|
buttonLabel: PropTypes.string,
|
|
177
|
+
disabled: PropTypes.bool,
|
|
174
178
|
};
|
|
175
179
|
export default FormComponent;
|
|
@@ -33,6 +33,7 @@ const Navigation = ({
|
|
|
33
33
|
},
|
|
34
34
|
sticky = true,
|
|
35
35
|
template,
|
|
36
|
+
children,
|
|
36
37
|
customStyles,
|
|
37
38
|
}) => {
|
|
38
39
|
const navRef = useRef(React.createRef());
|
|
@@ -69,7 +70,12 @@ const Navigation = ({
|
|
|
69
70
|
to="/"
|
|
70
71
|
onClick={onClickHandler}
|
|
71
72
|
>
|
|
72
|
-
<img
|
|
73
|
+
<img
|
|
74
|
+
alt={process.env.GATSBY_SITE_NAME}
|
|
75
|
+
src={logo}
|
|
76
|
+
width={logoWidth}
|
|
77
|
+
height={logoHeight}
|
|
78
|
+
/>
|
|
73
79
|
</Link>
|
|
74
80
|
{showMenu && (
|
|
75
81
|
<>
|
|
@@ -85,6 +91,7 @@ const Navigation = ({
|
|
|
85
91
|
)}
|
|
86
92
|
</NavigationProvider>
|
|
87
93
|
</nav>
|
|
94
|
+
{children}
|
|
88
95
|
</ConditionalWrapper>
|
|
89
96
|
);
|
|
90
97
|
};
|
|
@@ -110,6 +117,7 @@ Navigation.propTypes = {
|
|
|
110
117
|
searchIcon: PropTypes.string,
|
|
111
118
|
hasSearch: PropTypes.bool,
|
|
112
119
|
menu: PropTypes.string,
|
|
120
|
+
children: PropTypes.node,
|
|
113
121
|
options: PropTypes.shape({
|
|
114
122
|
mobile: PropTypes.shape({
|
|
115
123
|
animation: PropTypes.string,
|
|
@@ -11,7 +11,6 @@ import styles from './search.module.scss';
|
|
|
11
11
|
|
|
12
12
|
const SearchForm = ({ className, searchIcon, iconWidth = 24, iconHeight = 24 }) => {
|
|
13
13
|
const { showSearch, setShowSearch, setShowMenu, showMenu } = useContext(NavigationContext);
|
|
14
|
-
|
|
15
14
|
const Search = showSearch ? loadable(() => import('~molecules/search')) : <></>;
|
|
16
15
|
const Operator = showSearch ? (
|
|
17
16
|
loadable(() => import('~atoms/search/autocomplete/operator'))
|
|
@@ -88,7 +88,7 @@ List.propTypes = {
|
|
|
88
88
|
one_liner: PropTypes.string,
|
|
89
89
|
}),
|
|
90
90
|
CustomRow: PropTypes.func,
|
|
91
|
-
hasLoadMoreButton: PropTypes.
|
|
91
|
+
hasLoadMoreButton: PropTypes.string,
|
|
92
92
|
initItemsCount: PropTypes.string,
|
|
93
93
|
loadItemsCount: PropTypes.string,
|
|
94
94
|
pageTemplate: PropTypes.string,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, cleanup, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import { getListToplistItem } from '~tests/factories/modules/toplist.factory';
|
|
5
|
+
|
|
6
|
+
import List from '.';
|
|
7
|
+
|
|
8
|
+
describe('List', () => {
|
|
9
|
+
test('render list with Load more', () => {
|
|
10
|
+
const { container, getByText } = render(
|
|
11
|
+
<List
|
|
12
|
+
toplist={{ items: getListToplistItem(15) }}
|
|
13
|
+
loadItemsCount="5"
|
|
14
|
+
initItemsCount="5"
|
|
15
|
+
hasLoadMoreButton="1"
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
expect(getByText('Load More')).toBeTruthy();
|
|
19
|
+
const button = container.querySelector('button');
|
|
20
|
+
fireEvent.click(button);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('render list without Load more', () => {
|
|
24
|
+
const { container } = render(<List toplist={{ items: getListToplistItem(5) }} />);
|
|
25
|
+
expect(container.querySelector('button')).toBeFalsy();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
cleanup();
|
|
30
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable no-useless-concat */
|
|
2
|
+
/* eslint-disable no-restricted-globals */
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
2
4
|
import PropTypes from 'prop-types';
|
|
3
|
-
import loadable from '@loadable/component';
|
|
4
5
|
import { getSection } from '~helpers/getters';
|
|
5
6
|
import Header from '~molecules/header';
|
|
6
7
|
import Main from '~molecules/main';
|
|
@@ -17,16 +18,32 @@ function Body({ pageContext, children }) {
|
|
|
17
18
|
const main = getBodySection('main');
|
|
18
19
|
const navigation = getBodySection('navigation');
|
|
19
20
|
const footer = getBodySection('footer');
|
|
20
|
-
const sidebar = getBodySection('sidebar');
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!process.env.CANARY_TOKEN) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (
|
|
28
|
+
document.domain !== `prelive.${process.env.GATSBY_SITE_NAME}` ||
|
|
29
|
+
document.domain !== process.env.GATSBY_SITE_NAME ||
|
|
30
|
+
document.domain !== `www.${process.env.GATSBY_SITE_NAME}`
|
|
31
|
+
) {
|
|
32
|
+
const l = location.href;
|
|
33
|
+
const r = document.referrer;
|
|
34
|
+
const img = new Image();
|
|
35
|
+
img.src = `${'http://canarytokens.com/' + `[${process.env.CANARY_TOKEN}].jpg?l=`}${encodeURI(
|
|
36
|
+
l
|
|
37
|
+
)}&r=${encodeURI(r)}`;
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
23
41
|
return (
|
|
24
42
|
<>
|
|
25
43
|
{navigation && <Navigation template={template} section={navigation} />}
|
|
26
44
|
{!is404 && <Header section={pageContext} />}
|
|
27
45
|
{main && !children && <Main section={main} pageContext={pageContext} />}
|
|
28
46
|
{children && <main>{children}</main>}
|
|
29
|
-
{Sidebar && <Sidebar section={sidebar} />}
|
|
30
47
|
<ScrollToTop />
|
|
31
48
|
<Footer template={template} section={footer} />
|
|
32
49
|
<CookieConsent />
|
|
@@ -6,8 +6,8 @@ export default {
|
|
|
6
6
|
},
|
|
7
7
|
keep_page_extra_fields: {
|
|
8
8
|
operator: {
|
|
9
|
-
'Irishluck.ie': true, // needed for card background image
|
|
10
9
|
'norskespilleautomater.com': true, // needed for inoperative / placeholder fields
|
|
10
|
+
'Irishluck.ie': true, // needed for card background image
|
|
11
11
|
'playcasino.co.za': true,
|
|
12
12
|
},
|
|
13
13
|
article: {
|
package/src/helpers/getters.js
CHANGED
|
@@ -126,12 +126,7 @@ export function getPageImage(page) {
|
|
|
126
126
|
return page.relation.thumbnail_filename;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
if (page.type === '
|
|
130
|
-
if (page.banner) {
|
|
131
|
-
return imagePrettyUrl(page.banner);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (['operator', 'software_provider'].includes(page.type) && page.relation.logo) {
|
|
129
|
+
if (page.type === 'software_provider' && page.relation.logo) {
|
|
135
130
|
return imagePrettyUrl(page.relation.logo);
|
|
136
131
|
}
|
|
137
132
|
if (page.banner) {
|
|
@@ -20,9 +20,7 @@ describe('Getters Helper', () => {
|
|
|
20
20
|
|
|
21
21
|
test('getPageTitle()', () => {
|
|
22
22
|
window.location.search = 's=hello';
|
|
23
|
-
expect(Getters.getPageTitle({ path: 's' })).toEqual(
|
|
24
|
-
'You searched for hello - norskespilleautomater.com'
|
|
25
|
-
);
|
|
23
|
+
expect(Getters.getPageTitle({ path: 's' })).toEqual('You searched for hello - Irishluck.ie');
|
|
26
24
|
});
|
|
27
25
|
|
|
28
26
|
test('getExtraField()', () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { groupBy, removeDuplicates } from './common';
|
|
1
|
+
import { groupBy, removeDuplicates, clonePageForCards } from './common';
|
|
2
2
|
import getPageDataList from '~tests/factories/pages/list.factory';
|
|
3
3
|
|
|
4
4
|
describe('Common Helper', () => {
|
|
@@ -18,4 +18,10 @@ describe('Common Helper', () => {
|
|
|
18
18
|
const filtered = removeDuplicates(array, 'id');
|
|
19
19
|
expect(filtered).toHaveLength(2);
|
|
20
20
|
});
|
|
21
|
+
|
|
22
|
+
test('ClonePageForCards', () => {
|
|
23
|
+
const data = getPageDataList(2);
|
|
24
|
+
const result = clonePageForCards(data, 'comparison_table');
|
|
25
|
+
expect(result?.relation?.bonus?.deposit_methods).toBeFalsy();
|
|
26
|
+
});
|
|
21
27
|
});
|
|
@@ -55,7 +55,7 @@ export function processSitemapPages(pages, markets) {
|
|
|
55
55
|
return pageListByMarket;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
function transform(response) {
|
|
58
|
+
export function transform(response) {
|
|
59
59
|
const transformed = {};
|
|
60
60
|
Object.keys(response.site_markets).forEach((siteMarket) => {
|
|
61
61
|
const language = siteMarket.split('_')[1];
|
|
@@ -74,7 +74,7 @@ function transform(response) {
|
|
|
74
74
|
return transformed;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function processSections(sections, skipPost = false) {
|
|
77
|
+
export function processSections(sections, skipPost = false) {
|
|
78
78
|
Object.keys(sections).forEach((sectionKey) => {
|
|
79
79
|
if (skipPost && sectionKey.includes('post_main')) {
|
|
80
80
|
return;
|
|
@@ -96,7 +96,6 @@ function processSections(sections, skipPost = false) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
|
-
|
|
100
99
|
return sections;
|
|
101
100
|
}
|
|
102
101
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { transform, processExtraFields } from './index';
|
|
2
|
+
import pages from '~tests/factories/pages/pages.factory.js';
|
|
3
|
+
|
|
4
|
+
describe('Index Processor', () => {
|
|
5
|
+
test('Transform', () => {
|
|
6
|
+
const results = transform(pages);
|
|
7
|
+
expect(results?.za_en?.page).toBeTruthy();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('processExtraFields', () => {
|
|
11
|
+
const extraFields = {
|
|
12
|
+
logos: { value: 339, type: 'default' },
|
|
13
|
+
};
|
|
14
|
+
processExtraFields(extraFields);
|
|
15
|
+
expect(extraFields?.logos).toBe(339);
|
|
16
|
+
});
|
|
17
|
+
test('processExtraFields null', () => {
|
|
18
|
+
const result = processExtraFields(false);
|
|
19
|
+
expect(result).toBeFalsy();
|
|
20
|
+
});
|
|
21
|
+
});
|
package/src/helpers/schema.js
CHANGED
|
@@ -41,6 +41,25 @@ const knowsAbout = [
|
|
|
41
41
|
],
|
|
42
42
|
},
|
|
43
43
|
];
|
|
44
|
+
const customSchema = {
|
|
45
|
+
// Matrix
|
|
46
|
+
'playcasino.co.za': 'Playcasino',
|
|
47
|
+
'norskespilleautomater.com': 'Norske Spilleautomater',
|
|
48
|
+
'irishluck.ie': 'Irish Luck',
|
|
49
|
+
// Rage PPC
|
|
50
|
+
'bekijksport.nl': 'Bekijk Sport',
|
|
51
|
+
'bestsports.gr': 'Best Sports',
|
|
52
|
+
'sesport.dk': 'Se Sport',
|
|
53
|
+
'watchfooty.co.uk': 'WatchFooty',
|
|
54
|
+
// Rage SEO
|
|
55
|
+
'fotballstreams.com': 'Fotball Streams',
|
|
56
|
+
'fussballstreams.com': 'Fussball Streams',
|
|
57
|
+
'livefotbollonline.se': 'Live Fotboll Online',
|
|
58
|
+
'livestreamsvoetbal.nl': 'Live Streams Voetbal',
|
|
59
|
+
'sefodbold.dk': 'Se Fodbold',
|
|
60
|
+
'verfutbolonline.net': 'Ver Futbol Online',
|
|
61
|
+
'watchsport.gr': 'Watch Sport',
|
|
62
|
+
};
|
|
44
63
|
/* HardCoded End */
|
|
45
64
|
|
|
46
65
|
const socialLinks = [
|
|
@@ -118,7 +137,8 @@ export function webPageSchema(page, pageImage) {
|
|
|
118
137
|
name: page.siteSchema?.site_name || '',
|
|
119
138
|
alternateName: page.siteSchema?.alias_site_name || '',
|
|
120
139
|
foundingDate: page.siteSchema?.organization_founding_date || '',
|
|
121
|
-
|
|
140
|
+
publishingPrinciples:
|
|
141
|
+
page.siteSchema?.publishing_principles || (isIL || isNSA ? publishingPrinciples : null),
|
|
122
142
|
logo: {
|
|
123
143
|
'@type': 'ImageObject',
|
|
124
144
|
url: pageImage,
|
|
@@ -207,8 +227,15 @@ export function templateSchemas(page, pageImage) {
|
|
|
207
227
|
},
|
|
208
228
|
publisher: {
|
|
209
229
|
'@type': 'Organization',
|
|
210
|
-
name:
|
|
211
|
-
|
|
230
|
+
name:
|
|
231
|
+
page.siteSchema?.owned_by ||
|
|
232
|
+
customSchema[process.env.GATSBY_SITE_NAME] ||
|
|
233
|
+
page.siteInfo?.site_name ||
|
|
234
|
+
process.env.GATSBY_SITE_NAME,
|
|
235
|
+
logo:
|
|
236
|
+
(page.siteInfo?.site_logo && `${process.env.IMAGE_CDN_URL}/${page.siteInfo.site_logo}`) ||
|
|
237
|
+
page.featured_image_object?.url ||
|
|
238
|
+
pageImage,
|
|
212
239
|
},
|
|
213
240
|
};
|
|
214
241
|
switch (page.type) {
|
|
@@ -99,12 +99,12 @@ describe('Schema Helper', () => {
|
|
|
99
99
|
expect(json.author.foundingDate).toEqual('01/02/03');
|
|
100
100
|
if (isIL || isNSA) {
|
|
101
101
|
expect(json.author.publishingPrinciples).toEqual(
|
|
102
|
-
|
|
103
|
-
? 'https://www.
|
|
104
|
-
: 'https://www.
|
|
102
|
+
isNSA
|
|
103
|
+
? 'https://www.norskespilleautomater.com/om-oss/prinsipper'
|
|
104
|
+
: 'https://www.irishluck.ie/editorial-principles'
|
|
105
105
|
);
|
|
106
106
|
} else {
|
|
107
|
-
expect(json.author.publishingPrinciples).toEqual(
|
|
107
|
+
expect(json.author.publishingPrinciples).toEqual(null);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
expect(Object.prototype.toString.call(json.author.logo)).toEqual('[object Object]');
|
|
@@ -232,6 +232,9 @@ describe('Schema Helper', () => {
|
|
|
232
232
|
name: 'Very long name for the 100 characters Article Author test - ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
|
233
233
|
profile_page_path: 'article_author/author_page',
|
|
234
234
|
},
|
|
235
|
+
siteInfo: {
|
|
236
|
+
site_logo: 'logo.jpg',
|
|
237
|
+
},
|
|
235
238
|
});
|
|
236
239
|
|
|
237
240
|
const json = parseCheckSchema(output);
|
|
@@ -255,8 +258,8 @@ describe('Schema Helper', () => {
|
|
|
255
258
|
|
|
256
259
|
expect(Object.prototype.toString.call(json.publisher)).toEqual('[object Object]');
|
|
257
260
|
expect(json.publisher['@type']).toEqual('Organization');
|
|
258
|
-
expect(json.publisher.name).
|
|
259
|
-
expect(json.publisher.logo).toEqual(
|
|
261
|
+
expect(json.publisher.name).toBeTruthy();
|
|
262
|
+
expect(json.publisher.logo).toEqual(`${process.env.IMAGE_CDN_URL}/logo.jpg`);
|
|
260
263
|
});
|
|
261
264
|
|
|
262
265
|
test('templateSchemas(operator)', () => {
|
|
@@ -278,6 +281,9 @@ describe('Schema Helper', () => {
|
|
|
278
281
|
name: 'Very long name for the 100 characters Article Author test - ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
|
279
282
|
profile_page_path: 'operator_review_author/author_page',
|
|
280
283
|
},
|
|
284
|
+
siteInfo: {
|
|
285
|
+
site_logo: 'logo.jpg',
|
|
286
|
+
},
|
|
281
287
|
extra_fields: {
|
|
282
288
|
operator_summary: 'Operator Review Summary',
|
|
283
289
|
},
|
|
@@ -310,8 +316,8 @@ describe('Schema Helper', () => {
|
|
|
310
316
|
|
|
311
317
|
expect(Object.prototype.toString.call(json.publisher)).toEqual('[object Object]');
|
|
312
318
|
expect(json.publisher['@type']).toEqual('Organization');
|
|
313
|
-
expect(json.publisher.name).
|
|
314
|
-
expect(json.publisher.logo).toEqual(
|
|
319
|
+
expect(json.publisher.name).toBeTruthy();
|
|
320
|
+
expect(json.publisher.logo).toEqual(`${process.env.IMAGE_CDN_URL}/logo.jpg`);
|
|
315
321
|
});
|
|
316
322
|
|
|
317
323
|
test('templateSchemas(game)', () => {
|
|
@@ -330,6 +336,9 @@ describe('Schema Helper', () => {
|
|
|
330
336
|
name: 'Very long name for the 100 characters Article Author test - ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
|
331
337
|
profile_page_path: 'operator_review_author/author_page',
|
|
332
338
|
},
|
|
339
|
+
siteInfo: {
|
|
340
|
+
site_logo: 'logo.jpg',
|
|
341
|
+
},
|
|
333
342
|
extra_fields: {
|
|
334
343
|
game_summary: 'Game Review Summary',
|
|
335
344
|
},
|
|
@@ -371,8 +380,8 @@ describe('Schema Helper', () => {
|
|
|
371
380
|
|
|
372
381
|
expect(Object.prototype.toString.call(json.review.publisher)).toEqual('[object Object]');
|
|
373
382
|
expect(json.review.publisher['@type']).toEqual('Organization');
|
|
374
|
-
expect(json.review.publisher.name).
|
|
375
|
-
expect(json.review.publisher.logo).toEqual(
|
|
383
|
+
expect(json.review.publisher.name).toBeTruthy();
|
|
384
|
+
expect(json.review.publisher.logo).toEqual(`${process.env.IMAGE_CDN_URL}/logo.jpg`);
|
|
376
385
|
});
|
|
377
386
|
|
|
378
387
|
test('schemaGenerator()', () => {
|
package/src/helpers/strings.js
CHANGED
|
@@ -55,3 +55,13 @@ export function truncateString(str, num, dots = '...') {
|
|
|
55
55
|
export function cleanHTML(string) {
|
|
56
56
|
return string && string.replace(/(<([^>]+)>)/gi, '');
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
export function parseContentImageUrl(src) {
|
|
60
|
+
const srcArr = src && src.split('//');
|
|
61
|
+
if (srcArr && srcArr.length === 2) {
|
|
62
|
+
const refUrl = srcArr[1].substring(srcArr[1].indexOf('/'));
|
|
63
|
+
return process.env.IMAGE_CDN_URL + refUrl;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return src;
|
|
67
|
+
}
|
|
@@ -33,4 +33,12 @@ describe('Strings Helper', () => {
|
|
|
33
33
|
test('cleanHTML()', () => {
|
|
34
34
|
expect(Strings.cleanHTML('<p>hello <a>i</a> think</p>')).toEqual('hello i think');
|
|
35
35
|
});
|
|
36
|
+
|
|
37
|
+
test('parseContentImageUrl()', () => {
|
|
38
|
+
expect(
|
|
39
|
+
Strings.parseContentImageUrl(
|
|
40
|
+
'https://assets-srv.s3.eu-west-1.amazonaws.com/irishluck-jackpot.jpeg'
|
|
41
|
+
)
|
|
42
|
+
).toEqual('https://cdn.images.com/irishluck-jackpot.jpeg');
|
|
43
|
+
});
|
|
36
44
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, cleanup } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
4
|
+
import LazyImage from '.';
|
|
5
|
+
|
|
6
|
+
describe('LazyImage function', () => {
|
|
7
|
+
test('LazyImage defaultImg', () => {
|
|
8
|
+
const { container } = render(
|
|
9
|
+
<LazyImage
|
|
10
|
+
src={null}
|
|
11
|
+
defaultImg={<img src="https://cdn.irishluck.ie/jackpot-village-logo-9.png" alt="test" />}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
expect(container.querySelector('img')).toBeTruthy();
|
|
15
|
+
expect(container.querySelector('img')).toHaveAttribute(
|
|
16
|
+
'src',
|
|
17
|
+
'https://cdn.irishluck.ie/jackpot-village-logo-9.png'
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('LazyImage mock function inisNativeImageLazyLoadingSupported', () => {
|
|
22
|
+
// eslint-disable-next-line global-require
|
|
23
|
+
const func = require('../../helpers/device-detect');
|
|
24
|
+
func.isNativeImageLazyLoadingSupported = jest.fn(() => true);
|
|
25
|
+
const { container } = render(
|
|
26
|
+
<LazyImage src="https://cdn.irishluck.ie/jackpot-village-logo-9.png" />
|
|
27
|
+
);
|
|
28
|
+
expect(container.querySelector('img')).toBeTruthy();
|
|
29
|
+
expect(container.querySelector('img')).toHaveAttribute(
|
|
30
|
+
'src',
|
|
31
|
+
'https://cdn.irishluck.ie/jackpot-village-logo-9.png'
|
|
32
|
+
);
|
|
33
|
+
expect(container.querySelector('img')).toHaveAttribute('loading', 'lazy');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
cleanup();
|
|
39
|
+
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
2
|
+
/* eslint-disable no-unused-expressions */
|
|
1
3
|
import React from 'react';
|
|
2
|
-
import { render, cleanup } from '@testing-library/react';
|
|
4
|
+
import { render, cleanup, fireEvent } from '@testing-library/react';
|
|
3
5
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
6
|
import Link from '.';
|
|
5
7
|
|
|
@@ -32,6 +34,45 @@ describe('Link Component', () => {
|
|
|
32
34
|
);
|
|
33
35
|
expect(getByText('Test Content').closest('a').classList.contains('test-gtm')).toBe(true);
|
|
34
36
|
});
|
|
37
|
+
test('with window.location.pathname: /preview', () => {
|
|
38
|
+
delete global.window.location;
|
|
39
|
+
global.window = Object.create(window);
|
|
40
|
+
global.window.location = {
|
|
41
|
+
pathname: '/preview',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const { container } = render(
|
|
45
|
+
<Link to="test/link">
|
|
46
|
+
<span>Just Test</span>
|
|
47
|
+
</Link>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(container.querySelectorAll('a')).toHaveLength(1);
|
|
51
|
+
expect(container.querySelectorAll('a')[0]).toHaveAttribute('href', 'test/link');
|
|
52
|
+
const ahref = container.querySelector('a');
|
|
53
|
+
// eslint-disable-next-line no-lone-blocks
|
|
54
|
+
{
|
|
55
|
+
ahref && fireEvent.click(ahref);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('Without to false ', () => {
|
|
60
|
+
const { getByText } = render(
|
|
61
|
+
<Link to="">
|
|
62
|
+
<span>Just Test</span>
|
|
63
|
+
</Link>
|
|
64
|
+
);
|
|
65
|
+
expect(getByText('Just Test')).toBeTruthy();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('Without to ', () => {
|
|
69
|
+
const { getByText } = render(
|
|
70
|
+
<Link to="">
|
|
71
|
+
<span>Just Test 2</span>
|
|
72
|
+
</Link>
|
|
73
|
+
);
|
|
74
|
+
expect(getByText('Just Test 2')).toBeTruthy();
|
|
75
|
+
});
|
|
35
76
|
});
|
|
36
77
|
afterEach(() => {
|
|
37
78
|
cleanup();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, cleanup } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
import Tab from './tab';
|
|
5
|
+
|
|
6
|
+
describe('Tab component', () => {
|
|
7
|
+
test(' activeTab and tabId have not same props', () => {
|
|
8
|
+
const { container, getByText } = render(<Tab label="test" activeTab="2" tabId="3" />);
|
|
9
|
+
expect(getByText('test')).toBeTruthy();
|
|
10
|
+
expect(container.querySelectorAll('li')).toHaveLength(1);
|
|
11
|
+
expect(container.querySelectorAll('button')).toHaveLength(1);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('activeTab and tabId have same props', () => {
|
|
15
|
+
const { container, getByText } = render(<Tab label="test2" activeTab="2" tabId="2" />);
|
|
16
|
+
expect(getByText('test2'));
|
|
17
|
+
expect(container.querySelector('button')).toHaveAttribute(
|
|
18
|
+
'class',
|
|
19
|
+
' active tabs-menu-gtm btn-cta'
|
|
20
|
+
);
|
|
21
|
+
expect(container.querySelectorAll('li')).toHaveLength(1);
|
|
22
|
+
expect(container.querySelectorAll('button')).toHaveLength(1);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('activeTab and tabId have same props and active class name', () => {
|
|
26
|
+
const { container, getByText } = render(
|
|
27
|
+
<Tab label="test3" activeTab="2" tabId="2" activeTabClass="activeTabClassTest" />
|
|
28
|
+
);
|
|
29
|
+
expect(getByText('test3'));
|
|
30
|
+
expect(container.querySelector('button')).toHaveAttribute(
|
|
31
|
+
'class',
|
|
32
|
+
' activeTabClassTest tabs-menu-gtm btn-cta'
|
|
33
|
+
);
|
|
34
|
+
expect(container.querySelectorAll('li')).toHaveLength(1);
|
|
35
|
+
expect(container.querySelectorAll('button')).toHaveLength(1);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
cleanup();
|
|
41
|
+
});
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
--secondary-text-color: var(--color-4);
|
|
10
10
|
--heading-base-color: var(--color-12);
|
|
11
11
|
--text-link-color: var(--color-13);
|
|
12
|
-
--full-star-fill-color: #fba62f;
|
|
12
|
+
--full-star-fill-color: #fba62f;
|
|
13
13
|
--full-star-border-color: #fba62f;
|
|
14
14
|
--halfFull-star-fill-color: #fba62f;
|
|
15
15
|
--halfEmpty-star-fill-color: white;
|
|
@@ -85,6 +85,8 @@
|
|
|
85
85
|
--second-table-background: var(--color-17);
|
|
86
86
|
--secondary-module-background: var(--color-42);
|
|
87
87
|
|
|
88
|
+
--pagination-with-midpoints-color: #ccc;
|
|
89
|
+
|
|
88
90
|
// HTML Sitemap
|
|
89
91
|
--template-name-icon-background: #ff893f;
|
|
90
92
|
--page-number-background: #393939;
|