@@ -3,11 +3,13 @@ import React from 'react';
3
3
import ReactDOM from 'react-dom' ;
4
4
import TestUtils from 'react-addons-test-utils' ;
5
5
import { Provider } from 'react-redux' ;
6
- import { Tooltip , Origin } from '../../src/index' ;
6
+ import { Tooltip , Origin , utils } from '../../src/index' ;
7
7
import App from '../../examples/delay/app' ;
8
8
import store from '../../examples/common/store' ;
9
9
import { firstComponent , getStyleValue } from '../helpers' ;
10
10
11
+ const { position } = utils ;
12
+
11
13
describe ( 'Delay Example' , ( ) => {
12
14
before ( ( ) => {
13
15
document . body . innerHTML += '<div id="container" style="position:absolute;top:0;left:0;"></div>' ;
@@ -208,4 +210,30 @@ describe('Delay Example', () => {
208
210
assert ( getStyleValue ( tooltip , 'visibility' ) === 'hidden' , 'tooltip should be hidden' ) ;
209
211
} ) ;
210
212
} ) ;
213
+
214
+ describe ( 'timeout callback' , ( ) => {
215
+ it ( 'should be worked' , ( ) => {
216
+ // Mouseover and mouseout
217
+ const origin = firstComponent ( tree , Origin . WrappedComponent , { onTimeout : undefined } ) . refs . wrapper ;
218
+ TestUtils . Simulate . mouseEnter ( origin ) ;
219
+ TestUtils . Simulate . mouseLeave ( origin ) ;
220
+
221
+ const tooltip = firstComponent ( tree , Tooltip . WrappedComponent ) . refs . tooltip ;
222
+ assert ( getStyleValue ( tooltip , 'visibility' ) === 'visible' ) ;
223
+
224
+ const pos1 = position ( tooltip ) ;
225
+
226
+ // 2 seconds later
227
+ clock . tick ( 2000 ) ;
228
+ assert ( getStyleValue ( tooltip , 'visibility' ) === 'visible' ) ;
229
+
230
+ const pos2 = position ( tooltip ) ;
231
+ assert ( pos2 . left < pos1 . left ) ;
232
+ assert ( pos2 . top === pos1 . top ) ;
233
+
234
+ // 10 seconds later
235
+ clock . tick ( 10000 ) ;
236
+ assert ( getStyleValue ( tooltip , 'visibility' ) === 'visible' ) ;
237
+ } ) ;
238
+ } ) ;
211
239
} ) ;
0 commit comments