Skip to content

Commit

Permalink
Updating test case to include header load
Browse files Browse the repository at this point in the history
  • Loading branch information
bandana147 committed Sep 24, 2024
1 parent 5cf6df2 commit 738e644
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/utils/mocks/body-gnav.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<header></header>
<main>
<div>
<div class="gnav-brand logo">
<div>
<div><a
href="/federal/assets/svgs/adobe-logo.svg">https://main--federal--adobecom.hlx.page/federal/assets/svgs/adobe-logo.svg|Adobe,
Inc.</a> <a href="https://www.adobe.com/">Adobe</a></div>
</div>
</div>
</div>
<div>
<div class="large-menu section">
<div>
<div>
<h2 id="creativity--design"><a href="/federal/globalnav/drafts/blaishram/sections/section-menu-cc">Creativity
&#x26; Design</a></h2>
</div>
</div>
</div>
</div>
<div>
<div class="large-menu section">
<div>
<div>
<h2 id="help--support"><a href="/federal/globalnav/drafts/blaishram/sections/section-menu-helps">Help &#x26;
Support</a></h2>
</div>
</div>
</div>
</div>
<div>
<p><strong><a href="http://www.google.com/">Just link</a></strong></p>
</div>
<div></div>
</main>
8 changes: 8 additions & 0 deletions test/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ describe('Utils', () => {
});
});

it('renders global navigation when header tag is present', async ()=> {
const bodyWithheader = await readFile({ path: './mocks/body-gnav.html' });
document.head.innerHTML = head;
document.body.innerHTML = bodyWithheader;
await utils.loadArea();
expect(document.querySelector('.global-navigation')).to.exist;
});

describe('with body', () => {
beforeEach(async () => {
window.fetch = mockFetch({ payload: { data: '' } });
Expand Down

0 comments on commit 738e644

Please sign in to comment.