Skip to content

Commit

Permalink
Fixed unit tests for gnav promo
Browse files Browse the repository at this point in the history
  • Loading branch information
sharmrj committed Jan 8, 2025
1 parent 8e86f07 commit 4addfef
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/blocks/global-navigation/test-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@ export const createFullGlobalNavigation = async ({
hasBreadcrumbs = true,
unavContent = null,
} = {}) => {
const clock = sinon.useFakeTimers({
// Intercept setTimeout and call the function immediately
toFake: ['setTimeout'],
});
const clock = sinon.useFakeTimers({ shouldAdvanceTime: true });
setConfig({ ...config, ...customConfig });
await setViewport(viewports[viewport]);
window.lana = { log: stub() };
Expand All @@ -198,6 +195,7 @@ export const createFullGlobalNavigation = async ({
return null;
});
window.adobeIMS = {
initialized: true,
isSignedInUser: stub().returns(signedIn),
getAccessToken: stub().returns('mock-access-token'),
getProfile: stub().returns(
Expand Down Expand Up @@ -228,9 +226,11 @@ export const createFullGlobalNavigation = async ({
const instancePromise = initGnav(document.body.querySelector('header'));

await clock.runToLastAsync();
clock.tick(1000);
const instance = await instancePromise;
const imsPromise = instance.imsReady();
await clock.runToLastAsync();
clock.tick(1000);
// We restore the clock here, because waitForElement uses setTimeout
clock.restore();

Expand Down

0 comments on commit 4addfef

Please sign in to comment.