Skip to content

Commit

Permalink
Adding UT
Browse files Browse the repository at this point in the history
  • Loading branch information
Snehal Sonawane committed Dec 17, 2024
1 parent 77550e6 commit 6e302d7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/blocks/global-navigation/global-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,11 @@ describe('global navigation', () => {

it('should handle message events correctly', async () => {
// eslint-disable-next-line max-len
const mockEvent = (name, payload) => ({ detail: { name, payload, executeDefaultAction: sinon.spy(() => Promise.resolve({})) } });
const mockEvent = (name, payload) => ({ detail: { name, payload, executeDefaultAction: sinon.spy(() => Promise.resolve(null)) } });
await createFullGlobalNavigation({ unavContent: 'on' });
const { messageEventListener } = window.UniversalNav.getCall(0).args[0].children
.find((c) => c.name === 'profile').attributes;
const messageEventListener = window.UniversalNav.getCall(0).args[0].children
.map((c) => c.attributes.messageEventListener)
.find((listener) => listener);

const appInitiatedEvent = mockEvent('System', { subType: 'AppInitiated' });
messageEventListener(appInitiatedEvent);
Expand All @@ -445,6 +446,10 @@ describe('global navigation', () => {
const signOutEvent = mockEvent('System', { subType: 'SignOut' });
messageEventListener(signOutEvent);
expect(signOutEvent.detail.executeDefaultAction.called).to.be.true;

const profileSwitch = mockEvent('System', { subType: 'ProfileSwitch' });
messageEventListener(profileSwitch);
expect(profileSwitch.detail.executeDefaultAction.called).to.be.true;
});

it('should send the correct analytics events', async () => {
Expand Down

0 comments on commit 6e302d7

Please sign in to comment.