From 4addfef658baa223bab5fc126940aa842cb81e01 Mon Sep 17 00:00:00 2001 From: Raghav Sharma Date: Wed, 8 Jan 2025 12:36:04 +0530 Subject: [PATCH] Fixed unit tests for gnav promo --- test/blocks/global-navigation/test-utilities.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/blocks/global-navigation/test-utilities.js b/test/blocks/global-navigation/test-utilities.js index 762f9e63be..a474b66a7d 100644 --- a/test/blocks/global-navigation/test-utilities.js +++ b/test/blocks/global-navigation/test-utilities.js @@ -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() }; @@ -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( @@ -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();