Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dnicolson authored and diasbruno committed Feb 8, 2024
1 parent 7c1d947 commit 6724a04
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,11 @@ export default () => {
};
const node = createHTMLElement("div");
const modal = ReactDOM.render(<Modal {...props} />, node);
requestAnimationFrame(() => {
const request = requestAnimationFrame(() => {
mcontent(modal).className.should.be.eql("myClass myClass_after-open");
ReactDOM.unmountComponentAtNode(node);
});
cancelAnimationFrame(request);
});
});

Expand All @@ -378,12 +379,13 @@ export default () => {
};
const node = createHTMLElement("div");
const modal = ReactDOM.render(<Modal {...props} />, node);
requestAnimationFrame(() => {
const request = requestAnimationFrame(() => {
moverlay(modal).className.should.be.eql(
"myOverlayClass myOverlayClass_after-open"
);
ReactDOM.unmountComponentAtNode(node);
});
cancelAnimationFrame(request);
});
});

Expand Down Expand Up @@ -562,7 +564,10 @@ export default () => {
ReactDOM.render(<Modal isOpen appElement={el} />, 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);
});
});

Expand Down Expand Up @@ -593,10 +598,13 @@ export default () => {
</div>
);

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);
});
});

Expand Down Expand Up @@ -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);
});
});

Expand All @@ -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);
});
});

Expand All @@ -683,13 +698,14 @@ export default () => {
const props = { isOpen: true };
const node = createHTMLElement("div");
const modal = ReactDOM.render(<Modal {...props} />, 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);
});
});

Expand Down

0 comments on commit 6724a04

Please sign in to comment.