forked from reactjs/react-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fixed] Allow ReactDOM.createPortal to be mocked in tests
Fixes reactjs#553 - PR reactjs#701 * Allow ReactDOM.createPortal to be mocked in tests (9cd0891) * add testability tests (6a67946) * linting (f29e7b0) * more linting (5992f97)
- Loading branch information
Showing
3 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-env mocha */ | ||
import ReactDOM from "react-dom"; | ||
import sinon from "sinon"; | ||
import { mcontent, renderModal, emptyDOM } from "./helper"; | ||
|
||
export default () => { | ||
afterEach("cleaned up all rendered modals", emptyDOM); | ||
|
||
it("renders as expected, initially", () => { | ||
const modal = renderModal({ isOpen: true }, "hello"); | ||
mcontent(modal).should.be.ok(); | ||
}); | ||
|
||
it("allows ReactDOM.createPortal to be overridden in real-time", () => { | ||
const createPortalSpy = sinon.spy(ReactDOM, "createPortal"); | ||
renderModal({ isOpen: true }, "hello"); | ||
createPortalSpy.called.should.be.ok(); | ||
ReactDOM.createPortal.restore(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters