|
| 1 | +import React from 'react'; |
| 2 | +import ReactTestUtils from 'react/lib/ReactTestUtils'; |
| 3 | +import ModalTrigger from '../src/ModalTrigger'; |
| 4 | + |
| 5 | +describe('ModalTrigger', function() { |
| 6 | + it('Should create ModalTrigger element', function() { |
| 7 | + let instance = ReactTestUtils.renderIntoDocument( |
| 8 | + <ModalTrigger modal={<div>test</div>}> |
| 9 | + <button>button</button> |
| 10 | + </ModalTrigger> |
| 11 | + ); |
| 12 | + let modalTrigger = instance.getDOMNode(); |
| 13 | + assert.equal(modalTrigger.nodeName, 'BUTTON'); |
| 14 | + }); |
| 15 | + |
| 16 | + it('Should pass ModalTrigger onMouseOver prop to children', function() { |
| 17 | + let called = false; |
| 18 | + let callback = function() { |
| 19 | + called = true; |
| 20 | + }; |
| 21 | + let instance = ReactTestUtils.renderIntoDocument( |
| 22 | + <ModalTrigger modal={<div>test</div>} onMouseOver={callback}> |
| 23 | + <button>button</button> |
| 24 | + </ModalTrigger> |
| 25 | + ); |
| 26 | + let modalTrigger = instance.getDOMNode(); |
| 27 | + ReactTestUtils.Simulate.mouseOver(modalTrigger); |
| 28 | + assert.equal(called, true); |
| 29 | + }); |
| 30 | + |
| 31 | + it('Should pass ModalTrigger onMouseOut prop to children', function() { |
| 32 | + let called = false; |
| 33 | + let callback = function() { |
| 34 | + called = true; |
| 35 | + }; |
| 36 | + let instance = ReactTestUtils.renderIntoDocument( |
| 37 | + <ModalTrigger modal={<div>test</div>} onMouseOut={callback}> |
| 38 | + <button>button</button> |
| 39 | + </ModalTrigger> |
| 40 | + ); |
| 41 | + let modalTrigger = instance.getDOMNode(); |
| 42 | + ReactTestUtils.Simulate.mouseOut(modalTrigger); |
| 43 | + assert.equal(called, true); |
| 44 | + }); |
| 45 | +}); |
0 commit comments