Skip to content

Commit

Permalink
extended unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-bogos committed May 28, 2024
1 parent 57d2426 commit f0d6d4d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 7 additions & 1 deletion libs/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ import {
// Production Domain
const prodDomains = ['milo.adobe.com'];

const stageDomainsMap = { 'www.adobe.com': 'www.stage.adobe.com' };
const stageDomainsMap = {
'www.adobe.com': 'www.stage.adobe.com',
'blog.adobe.com': 'blog.stage.adobe.com',
'business.adobe.com': 'business.stage.adobe.com',
'helpx.adobe.com': 'helpx.stage.adobe.com',
'news.adobe.com': 'news.stage.adobe.com',
};

const locales = {
'': { ietf: 'en-US', tk: 'hah7vzn.css' },
Expand Down
17 changes: 14 additions & 3 deletions test/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,21 @@ describe('Utils', () => {
});

it('should convert prod links to stage links on stage env', async () => {
const links = document.body.querySelectorAll('a[href*="www.adobe.com"]');
utils.setConfig({ ...config, env: { name: 'stage' }, stageDomainsMap: { 'www.adobe.com': 'www.stage.adobe.com' } });
const stageDomainsMap = {
'www.adobe.com': 'www.stage.adobe.com',
'blog.adobe.com': 'blog.stage.adobe.com',
'business.adobe.com': 'business.stage.adobe.com',
'helpx.adobe.com': 'helpx.stage.adobe.com',
'news.adobe.com': 'news.stage.adobe.com',
};
utils.setConfig({
...config,
env: { name: 'stage' },
stageDomainsMap,
});
const links = Object.keys(stageDomainsMap).map((prodDom) => document.body.appendChild(createTag('a', { href: `https://${prodDom}`, 'data-prod-dom': prodDom })));
await utils.decorateLinks(document.body);
for (const link of links) expect(link.hostname === 'www.stage.adobe.com').to.be.true;
links.forEach((l) => expect(l.hostname === stageDomainsMap[l.dataset.prodDom]).to.be.true);
});
});

Expand Down

0 comments on commit f0d6d4d

Please sign in to comment.