Skip to content

Commit 6724a04

Browse files
dnicolsondiasbruno
authored andcommitted
Fix tests
1 parent 7c1d947 commit 6724a04

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

Diff for: specs/Modal.spec.js

+25-9
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,11 @@ export default () => {
359359
};
360360
const node = createHTMLElement("div");
361361
const modal = ReactDOM.render(<Modal {...props} />, node);
362-
requestAnimationFrame(() => {
362+
const request = requestAnimationFrame(() => {
363363
mcontent(modal).className.should.be.eql("myClass myClass_after-open");
364364
ReactDOM.unmountComponentAtNode(node);
365365
});
366+
cancelAnimationFrame(request);
366367
});
367368
});
368369

@@ -378,12 +379,13 @@ export default () => {
378379
};
379380
const node = createHTMLElement("div");
380381
const modal = ReactDOM.render(<Modal {...props} />, node);
381-
requestAnimationFrame(() => {
382+
const request = requestAnimationFrame(() => {
382383
moverlay(modal).className.should.be.eql(
383384
"myOverlayClass myOverlayClass_after-open"
384385
);
385386
ReactDOM.unmountComponentAtNode(node);
386387
});
388+
cancelAnimationFrame(request);
387389
});
388390
});
389391

@@ -562,7 +564,10 @@ export default () => {
562564
ReactDOM.render(<Modal isOpen appElement={el} />, node);
563565
el.getAttribute("aria-hidden").should.be.eql("true");
564566
ReactDOM.unmountComponentAtNode(node);
565-
should(el.getAttribute("aria-hidden")).not.be.ok();
567+
const request = requestAnimationFrame(() => {
568+
should(el.getAttribute('aria-hidden')).not.be.ok();
569+
});
570+
cancelAnimationFrame(request);
566571
});
567572
});
568573

@@ -593,10 +598,13 @@ export default () => {
593598
</div>
594599
);
595600

596-
ReactDOM.render(updatedState, rootNode);
597-
should(appElement.getAttribute("aria-hidden")).not.be.ok();
601+
const request = requestAnimationFrame(() => {
602+
ReactDOM.render(updatedState, rootNode);
603+
should(appElement.getAttribute("aria-hidden")).not.be.ok();
598604

599-
ReactDOM.unmountComponentAtNode(rootNode);
605+
ReactDOM.unmountComponentAtNode(rootNode);
606+
});
607+
cancelAnimationFrame(request);
600608
});
601609
});
602610

@@ -652,7 +660,10 @@ export default () => {
652660
appElement.getAttribute("aria-hidden").should.be.eql("true");
653661
});
654662

655-
should(appElement.getAttribute("aria-hidden")).not.be.ok();
663+
const request = requestAnimationFrame(() => {
664+
should(appElement.getAttribute("aria-hidden")).not.be.ok();
665+
});
666+
cancelAnimationFrame(request);
656667
});
657668
});
658669

@@ -673,7 +684,11 @@ export default () => {
673684
});
674685
check("true");
675686
});
676-
should(appElement.getAttribute("aria-hidden")).not.be.ok();
687+
688+
const request = requestAnimationFrame(() => {
689+
should(appElement.getAttribute("aria-hidden")).not.be.ok();
690+
});
691+
cancelAnimationFrame(request);
677692
});
678693
});
679694

@@ -683,13 +698,14 @@ export default () => {
683698
const props = { isOpen: true };
684699
const node = createHTMLElement("div");
685700
const modal = ReactDOM.render(<Modal {...props} />, node);
686-
requestAnimationFrame(() => {
701+
const request = requestAnimationFrame(() => {
687702
const contentName = modal.portal.content.className;
688703
const overlayName = modal.portal.overlay.className;
689704
rg.test(contentName).should.be.ok();
690705
rg.test(overlayName).should.be.ok();
691706
ReactDOM.unmountComponentAtNode(node);
692707
});
708+
cancelAnimationFrame(request);
693709
});
694710
});
695711

0 commit comments

Comments
 (0)