From 9c1e5c410e3a1a8c5e98904123fcbc4d8c889f19 Mon Sep 17 00:00:00 2001 From: Mira Date: Fri, 13 Sep 2024 14:57:14 +0200 Subject: [PATCH] fixed unit test --- libs/blocks/merch/upgrade.js | 2 +- test/blocks/merch/upgrade.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/blocks/merch/upgrade.js b/libs/blocks/merch/upgrade.js index d659a5ee5fe..65791779bee 100644 --- a/libs/blocks/merch/upgrade.js +++ b/libs/blocks/merch/upgrade.js @@ -145,7 +145,7 @@ export default async function handleUpgradeOffer( window.location.hash = hash; window.addEventListener('milo:modal:closed', () => { window.location.hash = prevHash; - }); + }, { once: true }); } return getModal(null, { id: 'switch-modal', content, closeEvent: 'closeModal', class: ['upgrade-flow-modal'] }); }; diff --git a/test/blocks/merch/upgrade.test.js b/test/blocks/merch/upgrade.test.js index d7d458bbbff..795ce057f99 100644 --- a/test/blocks/merch/upgrade.test.js +++ b/test/blocks/merch/upgrade.test.js @@ -66,7 +66,7 @@ describe('Switch Modal (Upgrade Flow)', () => { window.location.hash = '#prev-hash'; await handler(new Event('click'), 'new-hash'); expect(window.location.hash).to.equal('#new-hash'); - window.dispatchEvent(new Event('milo:modal:closed')); + document.querySelector('.dialog-modal.upgrade-flow-modal').dispatchEvent(new Event('closeModal')); expect(window.location.hash).to.equal('#prev-hash'); window.location.hash = initialHash; });