Skip to content

Commit 6a67946

Browse files
author
Mike Deverell
committed
add testability tests
1 parent 9cd0891 commit 6a67946

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

specs/Modal.testability.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import ReactDOM from "react-dom";
2+
import sinon from "sinon";
3+
import {
4+
mcontent,
5+
renderModal,
6+
emptyDOM
7+
} from "./helper";
8+
9+
export default () => {
10+
afterEach("cleaned up all rendered modals", emptyDOM);
11+
12+
it("renders as expected, initially", () => {
13+
const modal = renderModal({ isOpen: true }, "hello");
14+
mcontent(modal).should.be.ok();
15+
});
16+
17+
it("allows ReactDOM.createPortal to be overridden in real-time", () => {
18+
const createPortalSpy = sinon.spy(ReactDOM, "createPortal");
19+
renderModal({ isOpen: true }, "hello");
20+
createPortalSpy.called.should.be.ok();
21+
ReactDOM.createPortal.restore();
22+
});
23+
};

specs/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import ModalState from "./Modal.spec";
44
import ModalEvents from "./Modal.events.spec";
55
import ModalStyle from "./Modal.style.spec";
66
import ModalHelpers from "./Modal.helpers.spec";
7+
import ModalTestability from "./Modal.testability.spec";
78

89
describe("State", ModalState);
910
describe("Style", ModalStyle);
1011
describe("Events", ModalEvents);
1112
describe("Helpers", ModalHelpers);
13+
describe("Testability", ModalTestability);

0 commit comments

Comments
 (0)