React Bootstrap Test Fiddle
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://fb.me/react-with-addons-0.14.2.js"></script>
<script src="https://fb.me/react-dom-0.14.2.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap/0.27.3/react-bootstrap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine-html.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/boot.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.3.4/jasmine.css">
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
describe('Dialog', function() {
var TestUtils = React.addons.TestUtils;
var node;
beforeEach(function() {
node = document.createElement('div');
document.body.appendChild(node);
});
afterEach(function() {
ReactDOM.unmountComponentAtNode(node);
document.body.removeChild(node);
});
it('Should have title component', function() {
var noOp = function() {};
var instance = ReactDOM.render(
<ReactBootstrap.Modal show onHide={noOp} animation={false}>
<ReactBootstrap.Modal.Header>
<ReactBootstrap.Modal.Title>Test Dialog Title</ReactBootstrap.Modal.Title>
</ReactBootstrap.Modal.Header>
</ReactBootstrap.Modal>,
node);
// This test fails. Find DOM Node.
var instanceDomNode = ReactDOM.findDOMNode(instance);
expect(instanceDomNode).not.toBe(null);
// This test passes. Find Modal component.
var component = TestUtils.findRenderedComponentWithType(instance, ReactBootstrap.Modal);
expect(component).not.toBe(null);
// Error: Did not find exactly one match for componentType:function ModalHeader()...
//var headerComponent = TestUtils.findRenderedComponentWithType(component, ReactBootstrap.Modal.Header);
//expect(headerComponent).not.toBe(null);
//This test fails. Find modal header.
var headerComponents = TestUtils.scryRenderedComponentsWithType(component, ReactBootstrap.Modal.Header);
expect(headerComponents.length).not.toBe(0);
});
});