1
1
import _ from 'lodash'
2
2
import React from 'react'
3
- import { shallow } from 'enzyme'
3
+ import { mount , shallow } from 'enzyme'
4
+ import sinon from 'sinon'
4
5
5
6
import PortalPopper from './portal-popper'
6
7
@@ -11,9 +12,9 @@ const defaultProps = {
11
12
title : 'Do foo' ,
12
13
}
13
14
14
- const createComponent = ( props ) => (
15
+ const createComponent = ( props , child ) => (
15
16
< Tooltip { ..._ . extend ( { } , defaultProps , props ) } >
16
- < div className = 'target' />
17
+ { child || < div className = 'target' /> }
17
18
</ Tooltip >
18
19
)
19
20
@@ -48,6 +49,22 @@ describe('<Tooltip />', () => {
48
49
expect ( component . find ( 'span' ) ) . to . have . className ( 'custom-wrap-class' )
49
50
} )
50
51
52
+ it ( 'calls onMouseOver if specified' , ( ) => {
53
+ const onMouseOver = sinon . spy ( )
54
+ const component = mount ( createComponent ( { } , < div onMouseOver = { onMouseOver } /> ) )
55
+ const args = [ 1 , 2 , 3 ]
56
+ component . find ( 'div' ) . prop ( 'onMouseOver' ) ( ...args )
57
+ expect ( onMouseOver ) . to . be . calledWith ( ...args )
58
+ } )
59
+
60
+ it ( 'calls onMouseOut if specified' , ( ) => {
61
+ const onMouseOut = sinon . spy ( )
62
+ const component = mount ( createComponent ( { } , < div onMouseOut = { onMouseOut } /> ) )
63
+ const args = [ 1 , 2 , 3 ]
64
+ component . find ( 'div' ) . prop ( 'onMouseOut' ) ( ...args )
65
+ expect ( onMouseOut ) . to . be . calledWith ( ...args )
66
+ } )
67
+
51
68
describe ( 'when visible is not explicitly specified' , ( ) => {
52
69
let component
53
70
beforeEach ( ( ) => {
0 commit comments