Skip to content

Instantly share code, notes, and snippets.

@jkimbo
Last active November 11, 2015 22:56
Show Gist options
  • Save jkimbo/872f42732e6c772bf8e1 to your computer and use it in GitHub Desktop.
Save jkimbo/872f42732e6c772bf8e1 to your computer and use it in GitHub Desktop.
import assert from 'assert';
import jsdom from 'mocha-jsdom';
let React;
let TestUtils;
describe('Modal test', () => {
jsdom();
beforeEach(() => {
React = require('react');
TestUtils = require('react-addons-test-utils');
});
it('should be able to use TestUtils', () => {
const Modal = require('react-modal');
const renderedModal = TestUtils.renderIntoDocument(
<Modal isOpen={true}>
<div className="my-modal-class">
<h1>Hi!</h1>
</div>
</Modal>
);
const divs = TestUtils.scryRenderedDOMComponentsWithClass(renderedModal.portal, "my-modal-class");
assert.equal(divs.length, 1);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment