diff --git a/test/blocks/global-navigation/global-navigation.test.js b/test/blocks/global-navigation/global-navigation.test.js index 388233b81c..3940e95d36 100644 --- a/test/blocks/global-navigation/global-navigation.test.js +++ b/test/blocks/global-navigation/global-navigation.test.js @@ -396,6 +396,7 @@ describe('global navigation', () => { }); window.UniversalNav = sinon.spy(() => Promise.resolve()); window.UniversalNav.reload = sinon.spy(() => Promise.resolve()); + window.adobeProfile = { getUserProfile: sinon.spy(() => Promise.resolve({})) }; // eslint-disable-next-line no-underscore-dangle window._satellite = { track: sinon.spy() }; window.alloy = () => new Promise((resolve) => { @@ -430,6 +431,22 @@ describe('global navigation', () => { expect(window.UniversalNav.reload.getCall(0)).to.exist; }); + 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({})) } }); + await createFullGlobalNavigation({ unavContent: 'on' }); + const { messageEventListener } = window.UniversalNav.getCall(0).args[0].children + .find((c) => c.name === 'profile').attributes; + + const appInitiatedEvent = mockEvent('System', { subType: 'AppInitiated' }); + messageEventListener(appInitiatedEvent); + expect(window.adobeProfile.getUserProfile.called).to.be.true; + + const signOutEvent = mockEvent('System', { subType: 'SignOut' }); + messageEventListener(signOutEvent); + expect(signOutEvent.detail.executeDefaultAction.called).to.be.true; + }); + it('should send the correct analytics events', async () => { await createFullGlobalNavigation({ unavContent: 'on' }); const analyticsFn = window.UniversalNav.getCall(0) @@ -484,6 +501,14 @@ describe('global navigation', () => { expect(getUniversalNavLocale({ prefix: data.prefix })).to.equal(data.expectedLocale); } }); + + it('should pass enableProfileSwitcher to the profile component configuration', async () => { + await createFullGlobalNavigation({ unavContent: 'on' }); + const profileConfig = window.UniversalNav.getCall(0).args[0].children + .find((c) => c.name === 'profile').attributes.componentLoaderConfig.config; + + expect(profileConfig.enableProfileSwitcher).to.be.true; + }); }); describe('small desktop', () => {