gatsby-core-theme 3.0.0 → 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 +59 -0
- package/__mocks__/gatsby.js +16 -4
- package/gatsby-node.esm.js +7 -1
- 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 +9 -11
- 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/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/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 +0 -1
- 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/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 +4 -6
- 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 +1 -1
- package/src/helpers/schema.test.js +4 -4
- 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
|
@@ -20,6 +20,133 @@ describe('Content Component', () => {
|
|
|
20
20
|
// expect(container.querySelector('img')).toBeFalsy();
|
|
21
21
|
// expect(container.querySelector('div.lazyload-placeholder')).toBeTruthy();
|
|
22
22
|
});
|
|
23
|
+
|
|
24
|
+
test('Iframe props', () => {
|
|
25
|
+
const iframeModule = {
|
|
26
|
+
anchor_label: 'Slot tips',
|
|
27
|
+
anchor_slug: 'slot-tips',
|
|
28
|
+
anchored: 1,
|
|
29
|
+
background_color: null,
|
|
30
|
+
extra_anchors: null,
|
|
31
|
+
module_title: 'Tips when Choosing Slot Machines',
|
|
32
|
+
module_title_tag: 'h2',
|
|
33
|
+
module_value_id: 208480,
|
|
34
|
+
name: 'content',
|
|
35
|
+
see_more_link: null,
|
|
36
|
+
show_more_content: null,
|
|
37
|
+
show_more_enabled: '0',
|
|
38
|
+
show_more_label: null,
|
|
39
|
+
style: 'content_frame_style',
|
|
40
|
+
style_id: 41,
|
|
41
|
+
tag: 'h2',
|
|
42
|
+
title: 'Tips when Choosing Slot Machines',
|
|
43
|
+
value: `
|
|
44
|
+
<p>
|
|
45
|
+
Whether youre a newcomer to the world of online gambling, or whether you are a seasoned player with a desire to keep abreast of whats happening in the industry, youll find all the information you need, right here on Playcasino.</p>
|
|
46
|
+
<p>
|
|
47
|
+
<img src="https://assets-srv.s3.eu-west-1.amazonaws.com/online-casinos-in-south-africa.jpg" width="929px" id="67595" height="266px" alt="Online Casinos in South Africa" title="Online Casinos in South Africa" class="content-image--align-center fr-fic fr-dib">
|
|
48
|
+
</p>
|
|
49
|
+
<p>
|
|
50
|
+
<img src="https://assets-srv.s3.eu-west-1.amazonaws.com/online-casinos-in-south-africa.jpg" width="929px" id="67595" height="266px" alt="Online Casinos in South Africa" title="Online Casinos in South Africa" class="content-image--align-right fr-fic fr-dib">
|
|
51
|
+
</p>
|
|
52
|
+
<p>
|
|
53
|
+
<img src="https://assets-srv.s3.eu-west-1.amazonaws.com/online-casinos-in-south-africa.jpg" width="929px" id="67595" height="266px" alt="Online Casinos in South Africa" title="Online Casinos in South Africa" class="content-image--align-left fr-fic fr-dib">
|
|
54
|
+
</p>
|
|
55
|
+
<p>
|
|
56
|
+
<img src="https://assets-srv.s3.eu-west-1.amazonaws.com/online-casinos-in-south-africa.jpg" width="929px" id="67595" height="266px" alt="Online Casinos in South Africa" title="Online Casinos in South Africa" class="content-image--float-right fr-fic fr-dib">
|
|
57
|
+
</p>
|
|
58
|
+
<p>
|
|
59
|
+
<img src="https://assets-srv.s3.eu-west-1.amazonaws.com/online-casinos-in-south-africa.jpg" width="929px" id="67595" height="266px" alt="Online Casinos in South Africa" title="Online Casinos in South Africa" class="content-image--float-left fr-fic fr-dib">
|
|
60
|
+
</p>
|
|
61
|
+
<p> </p>
|
|
62
|
+
<p>
|
|
63
|
+
<strong>1. Top Lists: </strong>
|
|
64
|
+
Our team loves putting together lists of all kinds, including
|
|
65
|
+
<a data-page-id="99259" href="/real-money-online-casinos">
|
|
66
|
+
top real money casinos
|
|
67
|
+
</a>
|
|
68
|
+
, top casino bonuses,
|
|
69
|
+
<a data-page-id="99338" href="/free-casinos-no-deposit-south-africa">
|
|
70
|
+
top no deposit bonus casinos
|
|
71
|
+
</a>
|
|
72
|
+
,
|
|
73
|
+
<a data-page-id="99254" href="/live-dealer-casinos-south-africa">top live dealer casinos</a>
|
|
74
|
+
,
|
|
75
|
+
<a data-page-id="99363" href="/sports-betting-listings">
|
|
76
|
+
top sportsbooks,
|
|
77
|
+
</a>
|
|
78
|
+
<a data-page-id="98607" href="/low-wagering-casino-bonuses">
|
|
79
|
+
top low wagering bonuses
|
|
80
|
+
</a>
|
|
81
|
+
etc.</p>
|
|
82
|
+
<p>
|
|
83
|
+
<strong>
|
|
84
|
+
2. Casino and Sportsbook Reviews:
|
|
85
|
+
</strong>
|
|
86
|
+
Every casino and sportsbook we recommend is extensively reviewed by our professional team. We look at everything from games and bonuses available, to issues such as fairness, payouts, and security. Well provide unbiased and
|
|
87
|
+
<a href="/online-casino-reviews">
|
|
88
|
+
objective reviews of the casinos
|
|
89
|
+
</a>
|
|
90
|
+
and sportsbooks listings, to help you make an educated decision before betting your bankroll at the site of any online or
|
|
91
|
+
<a data-page-id="99146" href="/land-based-casino-listings">land based casino
|
|
92
|
+
</a>
|
|
93
|
+
.</p><p><strong>3. Game Reviews:</strong> New games are released to the South African casino landscape every month. Youll find reviews of all these new games, as well as all the popular classics. Learn about the important features of<a data-page-id="98606" href="/slots"> new slots
|
|
94
|
+
</a>, real money slots, and table games, such as betting limits, themes, bonus features, free play and
|
|
95
|
+
<a data-page-id="99186" href="/progressive-jackpots">
|
|
96
|
+
progressive jackpots
|
|
97
|
+
</a>.
|
|
98
|
+
Discover exciting and rewarding new titles to spice up your gaming sessions.
|
|
99
|
+
</p>
|
|
100
|
+
<p>
|
|
101
|
+
<strong>4. Reviews on Software Providers:
|
|
102
|
+
</strong> The companies that provide fantastic games at the best SA online casinos are reviewed on this site. Well examine which providers are better than others and let you know why. Well list the games that make up their portfolio and tell you where you can find their titles.
|
|
103
|
+
</p>
|
|
104
|
+
<p>
|
|
105
|
+
<strong>
|
|
106
|
+
5. Reviews on Payment Methods:
|
|
107
|
+
</strong> Payment methods form the backbone for the secure transfer of funds into and from your
|
|
108
|
+
<a data-page-id="99253" href="/zar-online-casinos-south-africa">
|
|
109
|
+
ZAR-friendly casino accounts
|
|
110
|
+
</a> which is why we only recommend trusted and proven banking methods that are safe, easy and convenient for South Africans to use.
|
|
111
|
+
</p> <p>
|
|
112
|
+
<iframe width="960" height="560" src="https://www.youtube.com/embed/zdzQcsduee8" title="YouTube video player" frameborder="0" allowfullscreen="0">
|
|
113
|
+
</iframe>
|
|
114
|
+
</p>
|
|
115
|
+
<p>
|
|
116
|
+
<strong>
|
|
117
|
+
6. Guides:
|
|
118
|
+
</strong>
|
|
119
|
+
From
|
|
120
|
+
<a data-page-id="99185" href="/online-casino-gambling">
|
|
121
|
+
beginner guides and how-to-play guides
|
|
122
|
+
</a>
|
|
123
|
+
to more intermediate and advanced strategies and tips, we cover everything players need to know whether they are new or experienced.
|
|
124
|
+
</p>
|
|
125
|
+
<p>
|
|
126
|
+
<strong>
|
|
127
|
+
7. News:
|
|
128
|
+
</strong>
|
|
129
|
+
We are firm believers that to truly succeed in online gambling, you need to keep abreast of the
|
|
130
|
+
<a href="/blog">
|
|
131
|
+
latest news
|
|
132
|
+
</a>
|
|
133
|
+
and be informed about industry updates. We are proud of our regularly updated news page that tells you about the latest promotions and reports on industry-related developments, both in South Africa and in the greater global industry. Dont miss out on the informative content on everything you wish to know, including much needed data & math to check
|
|
134
|
+
<a data-page-id="98584" href="/blog/chances-you-win-south-african-lottery">
|
|
135
|
+
how likely you are to win the lottery
|
|
136
|
+
</a>
|
|
137
|
+
?
|
|
138
|
+
</p>
|
|
139
|
+
<p>
|
|
140
|
+
<iframe width="960" height="560" src="https://www.youtube.com/embed/zdzQcsduee8" title="YouTube video player" frameborder="0" allowfullscreen="0">
|
|
141
|
+
</iframe>
|
|
142
|
+
</p>
|
|
143
|
+
`,
|
|
144
|
+
};
|
|
145
|
+
const { container } = render(<Content module={iframeModule} />);
|
|
146
|
+
|
|
147
|
+
expect(container.querySelectorAll('iframe')).toBeTruthy();
|
|
148
|
+
expect(container.querySelectorAll('noscript').length).toEqual(5);
|
|
149
|
+
});
|
|
23
150
|
});
|
|
24
151
|
afterEach(() => {
|
|
25
152
|
cleanup();
|
|
@@ -20,6 +20,12 @@ describe('header component', () => {
|
|
|
20
20
|
// Testing image
|
|
21
21
|
expect(container.querySelector('img')).toBeTruthy();
|
|
22
22
|
});
|
|
23
|
+
|
|
24
|
+
test('render header', () => {
|
|
25
|
+
const { container } = render(<Header section={headerSection} content="<p>Hello</p>" />);
|
|
26
|
+
expect(container.querySelectorAll('header')).toHaveLength(1);
|
|
27
|
+
expect(container.querySelectorAll('.headerContent')).toHaveLength(1);
|
|
28
|
+
});
|
|
23
29
|
});
|
|
24
30
|
afterEach(() => {
|
|
25
31
|
cleanup();
|
|
@@ -1,31 +1,67 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, cleanup
|
|
2
|
+
import { render, cleanup } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
|
|
5
5
|
import '~tests/helpers/match-media.mock';
|
|
6
6
|
import { getSingleContentData } from '~tests/factories/modules/content.factory';
|
|
7
7
|
import Main from '.';
|
|
8
|
+
import { schema, templatesInSchema } from '~tests/factories/modules/schema.factory.js';
|
|
8
9
|
|
|
9
|
-
const section = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const section = (title) => {
|
|
11
|
+
const data = {
|
|
12
|
+
modules: [
|
|
13
|
+
{
|
|
14
|
+
name: 'content',
|
|
15
|
+
...getSingleContentData('h2', 1, title),
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return data;
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
const pageObject = { page: { path: 's' } };
|
|
19
24
|
|
|
20
25
|
describe('Main Component', () => {
|
|
21
26
|
test('render main', async () => {
|
|
22
|
-
const
|
|
27
|
+
const sectionData = section('main');
|
|
28
|
+
const { container } = render(<Main section={sectionData} pageContext={pageObject} />);
|
|
29
|
+
expect(container).toBeTruthy();
|
|
30
|
+
expect(container.querySelectorAll('main.modulePage')).toHaveLength(1);
|
|
31
|
+
});
|
|
32
|
+
test('render main with author', async () => {
|
|
33
|
+
const sectionData = section('author');
|
|
34
|
+
const pageObjectSecond = { page: { path: 'author', author: {} } };
|
|
35
|
+
|
|
36
|
+
const { container } = render(<Main section={sectionData} pageContext={pageObjectSecond} />);
|
|
37
|
+
|
|
38
|
+
expect(container).toBeTruthy();
|
|
39
|
+
expect(container.querySelectorAll('main.modulePage')).toHaveLength(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('render main with sitemap as path', async () => {
|
|
43
|
+
const sectionData = section('sitemap');
|
|
44
|
+
|
|
45
|
+
const pageObjectSecond = {
|
|
46
|
+
page: { path: 'sitemap' },
|
|
47
|
+
templates: templatesInSchema,
|
|
48
|
+
sitemapData: schema,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const { container } = render(<Main section={sectionData} pageContext={pageObjectSecond} />);
|
|
52
|
+
|
|
23
53
|
expect(container).toBeTruthy();
|
|
24
54
|
expect(container.querySelectorAll('main.modulePage')).toHaveLength(1);
|
|
55
|
+
});
|
|
25
56
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
57
|
+
test('render main with 404 as path ', async () => {
|
|
58
|
+
const sectionData = section('404Sites');
|
|
59
|
+
|
|
60
|
+
const pageObjectSecond = { page: { path: '404', author: {} } };
|
|
61
|
+
|
|
62
|
+
const { container } = render(<Main section={sectionData} pageContext={pageObjectSecond} />);
|
|
63
|
+
expect(container).toBeTruthy();
|
|
64
|
+
expect(container.querySelectorAll('main.modulePage')).toHaveLength(1);
|
|
29
65
|
});
|
|
30
66
|
});
|
|
31
67
|
afterEach(() => {
|
|
@@ -52,6 +52,7 @@ describe('Menu Component', () => {
|
|
|
52
52
|
mobile: {
|
|
53
53
|
animation: 'collapse',
|
|
54
54
|
closeHandler: null,
|
|
55
|
+
stopScrollOnOpen: true,
|
|
55
56
|
},
|
|
56
57
|
desktop: {
|
|
57
58
|
orientation: 'horizontal',
|
|
@@ -64,6 +65,32 @@ describe('Menu Component', () => {
|
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
test('menu icon', () => {
|
|
68
|
+
const mockFn = jest.fn();
|
|
69
|
+
const { container } = render(
|
|
70
|
+
<NavigationProvider>
|
|
71
|
+
<Menu
|
|
72
|
+
section={menuSection.navigation}
|
|
73
|
+
menu={menuSection.menuList[0]}
|
|
74
|
+
options={{
|
|
75
|
+
mobile: {
|
|
76
|
+
animation: 'collapse',
|
|
77
|
+
closeHandler: mockFn,
|
|
78
|
+
},
|
|
79
|
+
desktop: {
|
|
80
|
+
orientation: 'horizontal',
|
|
81
|
+
},
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
</NavigationProvider>
|
|
85
|
+
);
|
|
86
|
+
expect(container.querySelectorAll('.menuIconContainer')).toHaveLength(1);
|
|
87
|
+
expect(container.querySelectorAll('.menuIcon')).toHaveLength(1);
|
|
88
|
+
fireEvent.click(container.querySelector('.menuIconContainer'));
|
|
89
|
+
fireEvent.keyDown(container.querySelector('.menuIconContainer'));
|
|
90
|
+
expect(mockFn).toHaveBeenCalled();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('test menu with children', () => {
|
|
67
94
|
const mockFn = jest.fn();
|
|
68
95
|
const { container } = render(
|
|
69
96
|
<NavigationProvider>
|
|
@@ -5,6 +5,39 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
5
5
|
import '~tests/helpers/match-media.mock';
|
|
6
6
|
import Module from '.';
|
|
7
7
|
import { getListContentData, contentTableOne } from '~tests/factories/modules/content.factory';
|
|
8
|
+
import { objectsHolder } from '~tests/factories/modules/modules.factory';
|
|
9
|
+
|
|
10
|
+
const getAnchorList = (number = 1) => {
|
|
11
|
+
function anchor(idNumber) {
|
|
12
|
+
return {
|
|
13
|
+
label: `Game Selection ${idNumber}`,
|
|
14
|
+
slug: `game-selection ${idNumber}`,
|
|
15
|
+
type: `module ${idNumber}`,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const arr = [];
|
|
20
|
+
for (let i = 0; i < number; i += 1) {
|
|
21
|
+
arr.push(anchor(i));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return arr;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getCaruselData = (number) => {
|
|
28
|
+
function caruselImg(idNumber) {
|
|
29
|
+
return {
|
|
30
|
+
image: `http://imgSrc//${idNumber}`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const arr = [];
|
|
35
|
+
for (let i = 0; i < number; i += 1) {
|
|
36
|
+
arr.push(caruselImg(i));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return arr;
|
|
40
|
+
};
|
|
8
41
|
|
|
9
42
|
describe('Modules Component ', () => {
|
|
10
43
|
test('render with props', async () => {
|
|
@@ -30,6 +63,107 @@ describe('Modules Component ', () => {
|
|
|
30
63
|
const { container } = render(<Module module={{ name: 'content', ...contentTableOne }} />);
|
|
31
64
|
expect(container.querySelectorAll('h2')).toHaveLength(0);
|
|
32
65
|
});
|
|
66
|
+
|
|
67
|
+
test('Swich for All component', () => {
|
|
68
|
+
const arr = [
|
|
69
|
+
'content',
|
|
70
|
+
'top_list',
|
|
71
|
+
'cards',
|
|
72
|
+
'cards_v2',
|
|
73
|
+
'pros_and_cons',
|
|
74
|
+
'accordion',
|
|
75
|
+
'bonus',
|
|
76
|
+
'image',
|
|
77
|
+
'spotlights',
|
|
78
|
+
];
|
|
79
|
+
arr.forEach((title) => {
|
|
80
|
+
const data = objectsHolder(title);
|
|
81
|
+
|
|
82
|
+
const { container } = render(
|
|
83
|
+
<Module
|
|
84
|
+
module={{
|
|
85
|
+
name: title,
|
|
86
|
+
anchor_label: title,
|
|
87
|
+
...data,
|
|
88
|
+
}}
|
|
89
|
+
page={{ template: 'default' }}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
expect(container.querySelector('div')).toBeTruthy();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('Anchor and archive without moduleItem items', () => {
|
|
98
|
+
const arr = ['archive', 'anchor'];
|
|
99
|
+
|
|
100
|
+
arr.forEach((elm) => {
|
|
101
|
+
const { container } = render(
|
|
102
|
+
<Module
|
|
103
|
+
module={{
|
|
104
|
+
name: elm,
|
|
105
|
+
items: [],
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
expect(container.querySelector('div')).toBe(null);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('Anchor and archive with moduleItem', () => {
|
|
114
|
+
const arr = ['archive', 'anchor'];
|
|
115
|
+
|
|
116
|
+
arr.forEach((elm) => {
|
|
117
|
+
const content = getAnchorList(3);
|
|
118
|
+
const { container } = render(
|
|
119
|
+
<Module
|
|
120
|
+
module={{
|
|
121
|
+
name: elm,
|
|
122
|
+
items: content,
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
// console.log('getByText(container)', getByText(container))
|
|
127
|
+
expect(container).toBeTruthy();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('carousel without data', () => {
|
|
132
|
+
const { container } = render(
|
|
133
|
+
<Module
|
|
134
|
+
module={{
|
|
135
|
+
name: 'carousel',
|
|
136
|
+
items: [{ image: null }],
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
expect(container.querySelector('div')).toBe(null);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test('carusel with data', () => {
|
|
145
|
+
const data = getCaruselData(3);
|
|
146
|
+
const { container } = render(
|
|
147
|
+
<Module
|
|
148
|
+
module={{
|
|
149
|
+
name: 'carousel',
|
|
150
|
+
items: data,
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
expect(container).toBeTruthy();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('module name is not in swich', () => {
|
|
158
|
+
const { container } = render(
|
|
159
|
+
<Module
|
|
160
|
+
module={{
|
|
161
|
+
name: 'test',
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
expect(container.querySelector('div')).toBe(null);
|
|
166
|
+
});
|
|
33
167
|
});
|
|
34
168
|
afterEach(() => {
|
|
35
169
|
cleanup();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/* eslint-disable no-lone-blocks */
|
|
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
|
|
|
5
7
|
import OperatorBanner from '.';
|
|
@@ -14,6 +16,10 @@ describe('OperatorBanner Component', () => {
|
|
|
14
16
|
expect(container.querySelectorAll('.sticky')).toHaveLength(1);
|
|
15
17
|
expect(getByText('Rizk Casino')).toBeTruthy();
|
|
16
18
|
expect(getByText('Visit')).toBeTruthy();
|
|
19
|
+
const button = container.querySelector('.closeBtn');
|
|
20
|
+
{
|
|
21
|
+
button && fireEvent.click(button);
|
|
22
|
+
}
|
|
17
23
|
});
|
|
18
24
|
test('render component placeholder', () => {
|
|
19
25
|
const data = getPageData();
|
|
@@ -1,60 +1,59 @@
|
|
|
1
1
|
.padd {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
padding: 0 1.15rem;
|
|
3
|
+
border-radius: var(--border-radius);
|
|
4
|
+
background-color: white;
|
|
5
|
+
margin: 0 0.4rem;
|
|
6
|
+
height: 4.8rem;
|
|
7
|
+
// TODO remove border
|
|
8
|
+
border: 1px solid var(--pagination-with-midpoints-color);
|
|
9
|
+
@include flex-align(center, center);
|
|
10
|
+
@media all and (max-width: 400px) {
|
|
11
|
+
margin: 0 0.1rem;
|
|
12
|
+
padding: 0 0.7rem;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
.pagination {
|
|
16
|
+
margin: 1rem auto;
|
|
17
|
+
@include flex-align(center, center);
|
|
18
|
+
|
|
19
|
+
a,
|
|
20
|
+
span {
|
|
21
|
+
color: var(--color-10);
|
|
22
|
+
display: inline-block;
|
|
23
|
+
font-size: 1.8rem;
|
|
24
|
+
line-height: 4.8rem;
|
|
6
25
|
height: 4.8rem;
|
|
7
|
-
// TODO remove border
|
|
8
|
-
border: 1px solid #ccc;
|
|
9
|
-
@include flex-align(center, center);
|
|
10
|
-
@media all and (max-width: 400px) {
|
|
11
|
-
margin: 0 0.1rem;
|
|
12
|
-
padding: 0 0.7rem;
|
|
13
|
-
}
|
|
14
26
|
}
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
a {
|
|
28
|
+
padding: 0 0.4rem;
|
|
29
|
+
}
|
|
30
|
+
.button {
|
|
17
31
|
@include flex-align(center, center);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
font-size: 2.5rem;
|
|
33
|
+
@extend .padd;
|
|
34
|
+
color: var(--color-7);
|
|
35
|
+
cursor: not-allowed;
|
|
36
|
+
&.isActive {
|
|
21
37
|
color: var(--color-10);
|
|
22
|
-
|
|
23
|
-
font-size: 1.8rem;
|
|
24
|
-
line-height: 4.8rem;
|
|
25
|
-
height: 4.8rem;
|
|
26
|
-
}
|
|
27
|
-
a {
|
|
28
|
-
padding: 0 0.4rem;
|
|
29
|
-
}
|
|
30
|
-
.button {
|
|
31
|
-
@include flex-align(center, center);
|
|
32
|
-
font-size: 2.5rem;
|
|
33
|
-
@extend .padd;
|
|
34
|
-
color: var(--color-7);
|
|
35
|
-
cursor: not-allowed;
|
|
36
|
-
&.isActive {
|
|
37
|
-
color: var(--color-10);
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
}
|
|
38
|
+
cursor: pointer;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.active {
|
|
43
|
+
color: var(--secondary-color);
|
|
44
|
+
}
|
|
45
|
+
li {
|
|
46
|
+
&.showInMobile {
|
|
47
|
+
display: none;
|
|
44
48
|
}
|
|
49
|
+
}
|
|
50
|
+
@include max(mobile) {
|
|
45
51
|
li {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@include max(mobile) {
|
|
51
|
-
li {
|
|
52
|
-
display: none;
|
|
53
|
-
&.showInMobile,
|
|
54
|
-
&.showInAll {
|
|
55
|
-
display: inline-block;
|
|
56
|
-
}
|
|
52
|
+
display: none;
|
|
53
|
+
&.showInMobile,
|
|
54
|
+
&.showInAll {
|
|
55
|
+
display: inline-block;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
|
|
59
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { navigate } from 'gatsby';
|
|
2
3
|
import { render, cleanup, fireEvent } from '@testing-library/react';
|
|
3
4
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
5
|
|
|
@@ -21,12 +22,17 @@ const setUp = () => {
|
|
|
21
22
|
return { container, getByText };
|
|
22
23
|
};
|
|
23
24
|
describe('cookie consent component', () => {
|
|
24
|
-
test('Children', () => {
|
|
25
|
+
test('Children and declineButton', () => {
|
|
25
26
|
const { container, getByText } = setUp();
|
|
27
|
+
|
|
26
28
|
expect(container.querySelectorAll('div.cookieConsent')).toHaveLength(1);
|
|
29
|
+
|
|
27
30
|
expect(container.querySelectorAll('p')).toHaveLength(1);
|
|
28
31
|
expect(container.querySelectorAll('b')).toHaveLength(1);
|
|
29
32
|
expect(getByText('cookie test')).toBeTruthy();
|
|
33
|
+
const declineButton = getByText('Decline Me');
|
|
34
|
+
fireEvent.click(declineButton);
|
|
35
|
+
expect(navigate).toHaveBeenCalled();
|
|
30
36
|
});
|
|
31
37
|
test('Buttons', () => {
|
|
32
38
|
const { container, getByText } = setUp();
|
|
@@ -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;
|