gatsby-core-theme 42.0.1 → 42.0.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/CHANGELOG.md +37 -0
- package/gatsby-node.mjs +8 -2
- package/package.json +1 -1
- package/src/components/molecules/floating-area/index.js +3 -1
- package/src/components/organisms/head/index.js +10 -4
- package/src/constants/pick-keys.mjs +25 -0
- package/src/constants/site-settings/navigation.js +6 -0
- package/src/helpers/api.mjs +13 -0
- package/src/helpers/fetch-site-settings.mjs +34 -4
- package/src/helpers/processor/common.mjs +1 -1
- package/src/helpers/processor/cryptos.mjs +71 -0
- package/src/helpers/processor/cryptos.test.js +27 -0
- package/src/helpers/processor/index.mjs +6 -3
- package/src/helpers/processor/relations.mjs +12 -0
- package/src/helpers/processor/relations.test.js +31 -0
- package/src/helpers/replaceMedia.js +103 -81
- package/src/helpers/replaceMedia.test.js +33 -0
- package/tests/factories/crypto-brokers/crypto-brokers.factory.js +126 -0
- package/tests/factories/crypto-exchanges/crypto-exchanges.factory.js +618 -0
- package/tests/factories/currencies/currencies.factory.js +62 -0
- package/tests/factories/pages/page.factory.js +6 -0
- package/tests/factories/relations/relation.factory.js +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
## [42.0.3](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v42.0.2...v42.0.3) (2025-02-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add checker ([586b529](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/586b5292d469676e995a7b0c6dddbfa7385b8b30))
|
|
7
|
+
* add tests ([24fe1b1](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/24fe1b19b46addca856bed2d727c46b90cffcc74))
|
|
8
|
+
* add traling slash on content and og:url ([4c1d918](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/4c1d9180e2e3c81ad965a6bc8f65c4fcf415e561))
|
|
9
|
+
* enabled mobile bottom navigation ([b3762c8](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/b3762c88226bf712fa0195e1178773d7aa0d4942))
|
|
10
|
+
* fix placeholder ([75a2619](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/75a261915fee687c451ac5fbc21ef8c21c14f101))
|
|
11
|
+
* update bottom navigation ([ae5fa79](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/ae5fa79b1216e0ff36056b7ffb2616828b81aff9))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* Merge branch 'fix-meta-title-placeholder' into 'master' ([8ced56d](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/8ced56d344ff6dea84077d869b168113d1a47bf8))
|
|
15
|
+
* Merge branch 'tm-5176-mobile-bottom-navigation' into 'master' ([9ce920b](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/9ce920b9ef19c0d8133ac43f8826df7a2990b8f6))
|
|
16
|
+
* Merge branch 'tm-5161-trailing-slash' into 'master' ([bb9060e](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/bb9060ee6ddda62657e8275f8f99fe573b136709))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Tests
|
|
20
|
+
|
|
21
|
+
* add test data ([97b604f](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/97b604f66925da7a6846ccc20e593a52d70e169b))
|
|
22
|
+
|
|
23
|
+
## [42.0.2](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v42.0.1...v42.0.2) (2025-02-05)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Code Refactoring
|
|
27
|
+
|
|
28
|
+
* changes to crypto endpoints ([5edcb95](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/5edcb95842d1e37d2f366a2fa784b29f049eba91))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
* Merge branch 'crypto-endpoints' into 'master' ([1a3f8b5](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/1a3f8b59901ea066c9352e59f1cc4d81ad83e165))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Tests
|
|
35
|
+
|
|
36
|
+
* add test ([c10989c](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/c10989cf8a0a2200dc09f626a913426d6713be57))
|
|
37
|
+
|
|
1
38
|
## [42.0.1](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v42.0.0...v42.0.1) (2025-02-04)
|
|
2
39
|
|
|
3
40
|
|
package/gatsby-node.mjs
CHANGED
|
@@ -46,6 +46,8 @@ let gamesData = null;
|
|
|
46
46
|
let sportsData = null;
|
|
47
47
|
let ribbonsData = null;
|
|
48
48
|
let operatorData = null;
|
|
49
|
+
let cryptoExchangesData = null;
|
|
50
|
+
let cryptoBrokersData = null;
|
|
49
51
|
let paymentData = null;
|
|
50
52
|
let allMarketPrefixes = [];
|
|
51
53
|
let allMarketSectionsData = null;
|
|
@@ -263,7 +265,9 @@ export const createPages = async (
|
|
|
263
265
|
payment_method: paymentData,
|
|
264
266
|
software_provider: providersData,
|
|
265
267
|
game: gamesData,
|
|
266
|
-
sports_data: sportsData
|
|
268
|
+
sports_data: sportsData,
|
|
269
|
+
crypto_exchanges: cryptoExchangesData,
|
|
270
|
+
crypto_brokers: cryptoBrokersData,
|
|
267
271
|
},
|
|
268
272
|
},
|
|
269
273
|
themeOptions,
|
|
@@ -505,7 +509,9 @@ export const onPreBootstrap = async () => {
|
|
|
505
509
|
paymentData,
|
|
506
510
|
providersData,
|
|
507
511
|
gamesData,
|
|
508
|
-
sportsData
|
|
512
|
+
sportsData,
|
|
513
|
+
cryptoExchangesData,
|
|
514
|
+
cryptoBrokersData,
|
|
509
515
|
} = await fetchSiteSettings(process.env.GATSBY_SITE_NAME));
|
|
510
516
|
};
|
|
511
517
|
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import CookieConsent from '~organisms/cookie-consent';
|
|
|
8
8
|
import isSticky from '~hooks/stickyOnScroll';
|
|
9
9
|
import { TrackingKeys } from '~constants/tracking-api'
|
|
10
10
|
import styles from './floating-area.module.scss';
|
|
11
|
+
import { layout } from '../../../constants/site-settings/navigation';
|
|
11
12
|
|
|
12
13
|
export default function FloatingArea({
|
|
13
14
|
pageContext,
|
|
@@ -20,6 +21,7 @@ export default function FloatingArea({
|
|
|
20
21
|
const showScroll = isSticky(offsetTop);
|
|
21
22
|
const [closedBanner, setClosedBanner] = useState(false);
|
|
22
23
|
const pageType = pageContext.page.relation_type;
|
|
24
|
+
const pageTemplate = pageContext?.page?.template
|
|
23
25
|
const getAllMarketsHomepage = () =>
|
|
24
26
|
Object.keys(pageContext?.allMarkets || {})?.map((elm) => elm.split('_')[1]) || [];
|
|
25
27
|
const isPageHomepage =
|
|
@@ -32,7 +34,7 @@ export default function FloatingArea({
|
|
|
32
34
|
: null;
|
|
33
35
|
|
|
34
36
|
const FooterNavigation =
|
|
35
|
-
footerNavigationData && footerNavigationData?.modules?.length > 0 && pageType !== 'operator'
|
|
37
|
+
footerNavigationData && footerNavigationData?.modules?.length > 0 && pageType !== 'operator'&& layout[pageTemplate]?.footerNavigation
|
|
36
38
|
? lazy(() => import(`gatsby-core-theme/src/components/organisms/footer-navigation`))
|
|
37
39
|
: null;
|
|
38
40
|
|
|
@@ -10,14 +10,19 @@ export function getLanguage(language) {
|
|
|
10
10
|
if (language === 'no') return 'nb-NO';
|
|
11
11
|
return language || 'en';
|
|
12
12
|
}
|
|
13
|
-
export function getCanonicalUrl(page) {
|
|
13
|
+
export function getCanonicalUrl(page, isTracker) {
|
|
14
14
|
if (page.canonical_url) {
|
|
15
15
|
return `${process.env.GATSBY_SITE_URL}${page.canonical_url}`;
|
|
16
16
|
}
|
|
17
17
|
if (page.path === '/') {
|
|
18
18
|
return process.env.GATSBY_SITE_URL;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
const trailingSlash = process.env.TRAILING_SLASH ? '/' : '';
|
|
21
|
+
|
|
22
|
+
return `${process.env.GATSBY_SITE_URL}${page.path.replace(/^\//, '')}${
|
|
23
|
+
!isTracker ? trailingSlash : ''
|
|
24
|
+
}`
|
|
25
|
+
|
|
21
26
|
}
|
|
22
27
|
export function getRobotOptions(options) {
|
|
23
28
|
const array = [];
|
|
@@ -39,6 +44,7 @@ function setName(string) {
|
|
|
39
44
|
|
|
40
45
|
const HeadData = ({ page = {}, siteInfo }) => {
|
|
41
46
|
const pageImage = getPageImage(page) ? getPageImage(page) : imagePrettyUrl(siteInfo?.site_logo);
|
|
47
|
+
const isTracker = page.template === 'tracker';
|
|
42
48
|
let defaultHref = null;
|
|
43
49
|
// When google re-indexes dev NSA and IRL, remove lines 28, 41, 42, 43 and process.env.GATSBY_ACTIVE_ENV !== 'development' from lines 24, 25, 27, 29, 43
|
|
44
50
|
return (
|
|
@@ -55,7 +61,7 @@ const HeadData = ({ page = {}, siteInfo }) => {
|
|
|
55
61
|
{process.env.GATSBY_ACTIVE_ENV === 'development' && (
|
|
56
62
|
<meta name="googlebot" content="noindex,follow" />
|
|
57
63
|
)}
|
|
58
|
-
<link rel="canonical" href={getCanonicalUrl(page)} />
|
|
64
|
+
<link rel="canonical" href={getCanonicalUrl(page, isTracker)} />
|
|
59
65
|
{page?.hreflangs?.map((link) => {
|
|
60
66
|
if (link?.default) defaultHref = link?.path;
|
|
61
67
|
return <link rel="alternate" href={getUrl(link.path)} hrefLang={link.language} />;
|
|
@@ -69,7 +75,7 @@ const HeadData = ({ page = {}, siteInfo }) => {
|
|
|
69
75
|
<meta name="og:description" content={page.meta_description} />
|
|
70
76
|
<meta name="og:type" content={page.path === '/' ? 'website' : 'article'} />
|
|
71
77
|
<meta name="og:image" content={pageImage} />
|
|
72
|
-
<meta name="og:url" content={
|
|
78
|
+
<meta name="og:url" content={getCanonicalUrl(page, isTracker)} />
|
|
73
79
|
<meta
|
|
74
80
|
property="og:locale"
|
|
75
81
|
content={getLanguage(page.language) === 'en' ? 'en_GB' : getLanguage(page.language)}
|
|
@@ -166,6 +166,31 @@ export const pickRelationKeys = {
|
|
|
166
166
|
payment_method: ["name", "rating", "logo", "selling_points", "id", "payout_time", "min_deposit", "support_types", "short_name", "iso_code", ],
|
|
167
167
|
country: ["id", "iso_code", "logo", "name", "code"],
|
|
168
168
|
currency: ["id", "name", "iso_code", "symbol", "crypto", "logo"],
|
|
169
|
+
crypto: [
|
|
170
|
+
"logo",
|
|
171
|
+
"id",
|
|
172
|
+
"selling_points",
|
|
173
|
+
"founded",
|
|
174
|
+
"name",
|
|
175
|
+
"rating_security",
|
|
176
|
+
"rating_fees",
|
|
177
|
+
"rating_usability",
|
|
178
|
+
"rating_features",
|
|
179
|
+
"rating_support",
|
|
180
|
+
"rating_average",
|
|
181
|
+
"short_name",
|
|
182
|
+
"links",
|
|
183
|
+
"email",
|
|
184
|
+
"url",
|
|
185
|
+
"markets_amount",
|
|
186
|
+
"support_types",
|
|
187
|
+
"headquarters",
|
|
188
|
+
"crypto_currencies",
|
|
189
|
+
"min_deposit",
|
|
190
|
+
"max_withdrawal",
|
|
191
|
+
"licences",
|
|
192
|
+
"services",
|
|
193
|
+
]
|
|
169
194
|
};
|
|
170
195
|
|
|
171
196
|
export const pickHTMLSitemapPageKeys = ["title", "path", "template_id"];
|
package/src/helpers/api.mjs
CHANGED
|
@@ -130,6 +130,19 @@ export async function getSports(siteName) {
|
|
|
130
130
|
return callAPIV2(`v0.1/sports/sorted/sorted-v2/${siteName}`);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
export async function getCryptoBrokers() {
|
|
134
|
+
return callAPIV2(`v0.1/cryptos/brokers/sorted`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export async function getCryptoExchanges() {
|
|
138
|
+
return callAPIV2(`v0.1/cryptos/exchanges/sorted`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// NOTE To be done later
|
|
142
|
+
export async function getCryptoWallets() {
|
|
143
|
+
return callAPIV2(`v0.1/cryptos/wallets/sorted`);
|
|
144
|
+
}
|
|
145
|
+
|
|
133
146
|
export async function getTeamJerseys(teamIds) {
|
|
134
147
|
const path = `https://enigma.micro7s.com/v1/sports-api/participants/teamkits?page_size=200`;
|
|
135
148
|
|
|
@@ -15,10 +15,14 @@ import {
|
|
|
15
15
|
getProviders,
|
|
16
16
|
getSports,
|
|
17
17
|
getTeamJerseys,
|
|
18
|
-
getGamesJackpot
|
|
18
|
+
getGamesJackpot,
|
|
19
|
+
getCryptoBrokers,
|
|
20
|
+
getCryptoExchanges,
|
|
21
|
+
getCryptoWallets,
|
|
19
22
|
} from "./api.mjs";
|
|
20
23
|
import { groupBy } from "./getters.mjs";
|
|
21
24
|
import { transformOperators } from "./processor/operators.mjs";
|
|
25
|
+
import { transformCryptosData } from "./processor/cryptos.mjs";
|
|
22
26
|
import { transformGames, transformGamesJackpot } from "./processor/games.mjs";
|
|
23
27
|
import { transformPayments } from "./processor/payment.mjs";
|
|
24
28
|
import { transformProvider } from "./processor/providers.mjs";
|
|
@@ -32,6 +36,11 @@ export const fetchSiteSettings = async (siteName) => {
|
|
|
32
36
|
const providersPromise = getProviders();
|
|
33
37
|
const gamblingCompaniesPromise = getGamblingCompanies();
|
|
34
38
|
|
|
39
|
+
// NOTE Crypto data
|
|
40
|
+
const cryptoBrokersPromise = getCryptoBrokers();
|
|
41
|
+
const cryptoExchangesPromise = getCryptoExchanges();
|
|
42
|
+
const cryptoWalletsPromise = getCryptoWallets();
|
|
43
|
+
|
|
35
44
|
// Wait for siteSettings to get siteId and then chain other requests
|
|
36
45
|
const siteSettingsData = await siteSettingsPromise;
|
|
37
46
|
const siteId = Object.keys(siteSettingsData.general)[0];
|
|
@@ -72,7 +81,10 @@ export const fetchSiteSettings = async (siteName) => {
|
|
|
72
81
|
providers,
|
|
73
82
|
games,
|
|
74
83
|
gamesJackpotData,
|
|
75
|
-
sportsData
|
|
84
|
+
sportsData,
|
|
85
|
+
cryptoBrokers,
|
|
86
|
+
cryptoExchanges,
|
|
87
|
+
cryptoWallets
|
|
76
88
|
] = await Promise.all([
|
|
77
89
|
ribbonsPromise,
|
|
78
90
|
responsableGamingPromise,
|
|
@@ -87,7 +99,10 @@ export const fetchSiteSettings = async (siteName) => {
|
|
|
87
99
|
providersPromise,
|
|
88
100
|
gamesPromise,
|
|
89
101
|
gamesJackpotPromise,
|
|
90
|
-
sportsPromise
|
|
102
|
+
sportsPromise,
|
|
103
|
+
cryptoBrokersPromise,
|
|
104
|
+
cryptoExchangesPromise,
|
|
105
|
+
cryptoWalletsPromise
|
|
91
106
|
]);
|
|
92
107
|
|
|
93
108
|
const allMarketPrefixes = Object.keys(allMarketsData)
|
|
@@ -116,6 +131,19 @@ export const fetchSiteSettings = async (siteName) => {
|
|
|
116
131
|
jackpot_data: transformGamesJackpot(gamesJackpotData)
|
|
117
132
|
});
|
|
118
133
|
|
|
134
|
+
const cryptoExchangesData = transformCryptosData(cryptoExchanges, {
|
|
135
|
+
countries: countriesData,
|
|
136
|
+
currencies: currenciesData,
|
|
137
|
+
payments: paymentData,
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
const cryptoBrokersData = transformCryptosData(cryptoBrokers, {
|
|
141
|
+
countries: countriesData,
|
|
142
|
+
currencies: currenciesData,
|
|
143
|
+
payments: paymentData,
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
|
|
119
147
|
if(["rage_seo", "rage_ppc", "sports"].includes(siteSettingsData.general[siteId].type)) {
|
|
120
148
|
const teamIds = Object.values(sportsData.teams).map((team) => String(team.livegoals_v2_id));
|
|
121
149
|
const teamKits = await getTeamJerseys(teamIds);
|
|
@@ -143,6 +171,8 @@ export const fetchSiteSettings = async (siteName) => {
|
|
|
143
171
|
paymentData,
|
|
144
172
|
providersData,
|
|
145
173
|
gamesData,
|
|
146
|
-
sportsData
|
|
174
|
+
sportsData,
|
|
175
|
+
cryptoExchangesData,
|
|
176
|
+
cryptoBrokersData
|
|
147
177
|
};
|
|
148
178
|
};
|
|
@@ -162,7 +162,7 @@ export function removeUnwantedSections(obj, pageType) {
|
|
|
162
162
|
games: ["post_main_games"],
|
|
163
163
|
operator: ['post_main_operators', "pre_main_operators", "recommended_casinos"],
|
|
164
164
|
article: ['post_main_articles'],
|
|
165
|
-
default: ['footer', 'links', 'navigation', 'popup', 'rg_navigation', 'sidebar']
|
|
165
|
+
default: ['footer', 'links', 'navigation', 'popup', 'rg_navigation', 'sidebar', 'footer_navigation']
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// Get sections to keep: merge default sections and specific sections for the key
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
|
+
import loadash from "lodash/index.js";
|
|
3
|
+
import {
|
|
4
|
+
processLogo,
|
|
5
|
+
processCountries,
|
|
6
|
+
processCurrencies,
|
|
7
|
+
processPaymentMethods,
|
|
8
|
+
} from "./relations.mjs";
|
|
9
|
+
import { pickRelationKeys } from "../../constants/pick-keys.mjs";
|
|
10
|
+
|
|
11
|
+
const { cloneDeep, pick } = loadash;
|
|
12
|
+
|
|
13
|
+
export function sanitizeCryptoData(data) {
|
|
14
|
+
const cryptoClone = cloneDeep(data);
|
|
15
|
+
|
|
16
|
+
return pick(cryptoClone, pickRelationKeys.crypto);
|
|
17
|
+
// return cryptoClone;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function transformCryptosData(jsonData, relationsData) {
|
|
21
|
+
const cryptos = {};
|
|
22
|
+
|
|
23
|
+
Object.values(jsonData).forEach(crypto => {
|
|
24
|
+
const newCryptoData = {
|
|
25
|
+
...crypto,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// OPERATOR LOGO (temp fix included and will be removed)
|
|
29
|
+
newCryptoData.logo = processLogo(
|
|
30
|
+
newCryptoData.logo,
|
|
31
|
+
newCryptoData.standardised_logo
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// DEPOSIT METHODS
|
|
35
|
+
if (newCryptoData.deposit_methods && Object.values(relationsData.payments).length) {
|
|
36
|
+
newCryptoData.deposit_methods = processPaymentMethods(
|
|
37
|
+
newCryptoData.deposit_methods,
|
|
38
|
+
newCryptoData.market,
|
|
39
|
+
relationsData.payments
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// CRYRPTO CURRENCIES
|
|
44
|
+
if ((newCryptoData.crypto_currencies || newCryptoData.currencies) && Object.values(relationsData.currencies).length) {
|
|
45
|
+
newCryptoData.crypto_currencies = processCurrencies(
|
|
46
|
+
newCryptoData.crypto_currencies || newCryptoData.currencies,
|
|
47
|
+
relationsData.currencies
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// FIAT CURRENCIES
|
|
52
|
+
if (newCryptoData.fiat_currencies && Object.values(relationsData.currencies).length) {
|
|
53
|
+
newCryptoData.fiat_currencies = processCurrencies(
|
|
54
|
+
newCryptoData.fiat_currencies,
|
|
55
|
+
relationsData.currencies
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// COUNTRIES
|
|
60
|
+
if (newCryptoData.restricted_countries && Object.values(relationsData.countries).length) {
|
|
61
|
+
newCryptoData.restricted_countries = processCountries(
|
|
62
|
+
newCryptoData.restricted_countries,
|
|
63
|
+
relationsData.countries
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
cryptos[crypto.id] = sanitizeCryptoData(newCryptoData);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return cryptos;
|
|
71
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cleanup, } from '@testing-library/react';
|
|
2
|
+
import { transformCryptosData } from './cryptos.mjs';
|
|
3
|
+
import { getCryptoExchangesList } from '../../../tests/factories/crypto-exchanges/crypto-exchanges.factory';
|
|
4
|
+
import getCurrenciesData from '../../../tests/factories/currencies/currencies.factory';
|
|
5
|
+
|
|
6
|
+
describe("Transform Cryptos Data", () => {
|
|
7
|
+
test('Transform Cryptos', () => {
|
|
8
|
+
const exchangesData = getCryptoExchangesList({ count: 3 });
|
|
9
|
+
// const operatorPage = getPageDataList(1);
|
|
10
|
+
|
|
11
|
+
const transformedCryptoExchanges = transformCryptosData(exchangesData, {payments: {}, currencies: getCurrenciesData(), countries: {}});
|
|
12
|
+
|
|
13
|
+
// values before transforming
|
|
14
|
+
expect(Object.values(exchangesData)[0].name).toBe('Crypto Exchange 1');
|
|
15
|
+
expect(Object.values(exchangesData)[2].name).toBe('Crypto Exchange 3');
|
|
16
|
+
expect(Object.values(exchangesData)[1].crypto_currencies.length).toBe(2);
|
|
17
|
+
expect(Object.values(exchangesData)[1].crypto_currencies[0]).toBe(1);
|
|
18
|
+
|
|
19
|
+
// values after transforming
|
|
20
|
+
expect(Object.values(transformedCryptoExchanges)[0].name).toBe('Crypto Exchange 1');
|
|
21
|
+
expect(Object.values(transformedCryptoExchanges)[1].crypto_currencies.length).toBe(2);
|
|
22
|
+
expect(Object.values(transformedCryptoExchanges)[1].crypto_currencies[0].name).toBe('Bitcoin');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
cleanup();
|
|
27
|
+
});
|
|
@@ -289,23 +289,26 @@ export function processExtraFields(
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
function updatePlaceholders(page, data, translationsData) {
|
|
292
|
+
|
|
292
293
|
page.title =
|
|
293
294
|
page.title &&
|
|
294
295
|
generatePlaceholderString(page.title, translationsData, {
|
|
295
296
|
siteName: data.site_name,
|
|
296
|
-
|
|
297
|
+
pageTitle: page.title
|
|
297
298
|
});
|
|
299
|
+
|
|
298
300
|
page.meta_title =
|
|
299
301
|
page.meta_title &&
|
|
300
302
|
generatePlaceholderString(page.meta_title, translationsData, {
|
|
301
303
|
siteName: data.site_name,
|
|
302
|
-
|
|
304
|
+
pageTitle: page.title
|
|
303
305
|
});
|
|
306
|
+
|
|
304
307
|
page.meta_description =
|
|
305
308
|
page.meta_description &&
|
|
306
309
|
generatePlaceholderString(page.meta_description, translationsData, {
|
|
307
310
|
siteName: data.site_name,
|
|
308
|
-
|
|
311
|
+
pageTitle: page.title
|
|
309
312
|
});
|
|
310
313
|
}
|
|
311
314
|
|
|
@@ -54,6 +54,18 @@ export const processRelations = (
|
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
break;
|
|
57
|
+
case "crypto_exchanges":
|
|
58
|
+
if (!hasRelation) {
|
|
59
|
+
transformedPages[market][pageType][index].relation =
|
|
60
|
+
data.relations.crypto_exchanges[page.relation_id];
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
case "crypto_brokers":
|
|
64
|
+
if (!hasRelation) {
|
|
65
|
+
transformedPages[market][pageType][index].relation =
|
|
66
|
+
data.relations.crypto_brokers[page.relation_id];
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
57
69
|
default:
|
|
58
70
|
break;
|
|
59
71
|
}
|
|
@@ -82,7 +82,38 @@ describe('Processor Relations', () => {
|
|
|
82
82
|
});
|
|
83
83
|
expect(pages[market][relation_type]).toHaveLength(1);
|
|
84
84
|
});
|
|
85
|
+
test('Crypto Exchanges', () => {
|
|
86
|
+
const relation_type = 'crypto_exchanges';
|
|
87
|
+
const market = 'ie_en';
|
|
88
|
+
const data = getData({ template: relation_type, count: 3 });
|
|
89
|
+
const pages = {
|
|
90
|
+
[market]: {
|
|
91
|
+
[relation_type]: getPageList({ template: relation_type, count: 3, relation_id: 2 })
|
|
92
|
+
},
|
|
93
|
+
};
|
|
85
94
|
|
|
95
|
+
pages[market][relation_type].forEach((page, index) => {
|
|
96
|
+
processRelations(page, relation_type, pages, market, data, index);
|
|
97
|
+
expect(page.relation_type).toEqual(relation_type);
|
|
98
|
+
});
|
|
99
|
+
expect(pages[market][relation_type]).toHaveLength(3);
|
|
100
|
+
});
|
|
101
|
+
test('Crypto Brokers', () => {
|
|
102
|
+
const relation_type = 'crypto_brokers';
|
|
103
|
+
const market = 'ie_en';
|
|
104
|
+
const data = getData({ template: relation_type, count: 3 });
|
|
105
|
+
const pages = {
|
|
106
|
+
[market]: {
|
|
107
|
+
[relation_type]: getPageList({ template: relation_type, count: 3, relation_id: 2 })
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
pages[market][relation_type].forEach((page, index) => {
|
|
112
|
+
processRelations(page, relation_type, pages, market, data, index);
|
|
113
|
+
expect(page.relation_type).toEqual(relation_type);
|
|
114
|
+
});
|
|
115
|
+
expect(pages[market][relation_type]).toHaveLength(3);
|
|
116
|
+
});
|
|
86
117
|
test('processCurrencies maps currencies with logos', () => {
|
|
87
118
|
const ids = [1, 2];
|
|
88
119
|
const currencies = {
|