Skip to content

Commit

Permalink
add testability tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Deverell committed Oct 15, 2018
1 parent 9cd0891 commit 6a67946
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions specs/Modal.testability.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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();
});
};
2 changes: 2 additions & 0 deletions specs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import ModalState from "./Modal.spec";
import ModalEvents from "./Modal.events.spec";
import ModalStyle from "./Modal.style.spec";
import ModalHelpers from "./Modal.helpers.spec";
import ModalTestability from "./Modal.testability.spec";

describe("State", ModalState);
describe("Style", ModalStyle);
describe("Events", ModalEvents);
describe("Helpers", ModalHelpers);
describe("Testability", ModalTestability);

0 comments on commit 6a67946

Please sign in to comment.