From 6724a049c1227eeb3cf06255c4bd9c90b4475e41 Mon Sep 17 00:00:00 2001 From: Dave Nicolson Date: Sat, 27 May 2023 12:25:00 +0200 Subject: [PATCH] Fix tests --- specs/Modal.spec.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/specs/Modal.spec.js b/specs/Modal.spec.js index c32db56e..60836313 100644 --- a/specs/Modal.spec.js +++ b/specs/Modal.spec.js @@ -359,10 +359,11 @@ export default () => { }; const node = createHTMLElement("div"); const modal = ReactDOM.render(, node); - requestAnimationFrame(() => { + const request = requestAnimationFrame(() => { mcontent(modal).className.should.be.eql("myClass myClass_after-open"); ReactDOM.unmountComponentAtNode(node); }); + cancelAnimationFrame(request); }); }); @@ -378,12 +379,13 @@ export default () => { }; const node = createHTMLElement("div"); const modal = ReactDOM.render(, node); - requestAnimationFrame(() => { + const request = requestAnimationFrame(() => { moverlay(modal).className.should.be.eql( "myOverlayClass myOverlayClass_after-open" ); ReactDOM.unmountComponentAtNode(node); }); + cancelAnimationFrame(request); }); }); @@ -562,7 +564,10 @@ export default () => { ReactDOM.render(, node); el.getAttribute("aria-hidden").should.be.eql("true"); ReactDOM.unmountComponentAtNode(node); - should(el.getAttribute("aria-hidden")).not.be.ok(); + const request = requestAnimationFrame(() => { + should(el.getAttribute('aria-hidden')).not.be.ok(); + }); + cancelAnimationFrame(request); }); }); @@ -593,10 +598,13 @@ export default () => { ); - ReactDOM.render(updatedState, rootNode); - should(appElement.getAttribute("aria-hidden")).not.be.ok(); + const request = requestAnimationFrame(() => { + ReactDOM.render(updatedState, rootNode); + should(appElement.getAttribute("aria-hidden")).not.be.ok(); - ReactDOM.unmountComponentAtNode(rootNode); + ReactDOM.unmountComponentAtNode(rootNode); + }); + cancelAnimationFrame(request); }); }); @@ -652,7 +660,10 @@ export default () => { appElement.getAttribute("aria-hidden").should.be.eql("true"); }); - should(appElement.getAttribute("aria-hidden")).not.be.ok(); + const request = requestAnimationFrame(() => { + should(appElement.getAttribute("aria-hidden")).not.be.ok(); + }); + cancelAnimationFrame(request); }); }); @@ -673,7 +684,11 @@ export default () => { }); check("true"); }); - should(appElement.getAttribute("aria-hidden")).not.be.ok(); + + const request = requestAnimationFrame(() => { + should(appElement.getAttribute("aria-hidden")).not.be.ok(); + }); + cancelAnimationFrame(request); }); }); @@ -683,13 +698,14 @@ export default () => { const props = { isOpen: true }; const node = createHTMLElement("div"); const modal = ReactDOM.render(, node); - requestAnimationFrame(() => { + const request = requestAnimationFrame(() => { const contentName = modal.portal.content.className; const overlayName = modal.portal.overlay.className; rg.test(contentName).should.be.ok(); rg.test(overlayName).should.be.ok(); ReactDOM.unmountComponentAtNode(node); }); + cancelAnimationFrame(request); }); });