@@ -9,47 +9,50 @@ var mouseEvent = require('../assets/mouse_event');
9
9
describe ( 'click event' , function ( ) {
10
10
var mock = require ( '@mocks/14.json' ) ;
11
11
12
- describe ( 'event data' , function ( ) {
13
- var mockCopy = Lib . extendDeep ( { } , mock ) ,
14
- clientX = 351 ,
15
- clientY = 223 ,
16
- gd ;
17
-
18
- function click ( ) {
19
- mouseEvent ( 'mousemove' , clientX , clientY ) ;
20
- mouseEvent ( 'mousedown' , clientX , clientY ) ;
21
- mouseEvent ( 'mouseup' , clientX , clientY ) ;
22
- }
23
-
24
- beforeEach ( function ( done ) {
25
- gd = createGraphDiv ( ) ;
26
-
27
- Plotly . plot ( gd , mockCopy . data , mockCopy . layout )
28
- . then ( done ) ;
12
+ afterEach ( destroyGraphDiv ) ;
13
+
14
+ var mockCopy = Lib . extendDeep ( { } , mock ) ,
15
+ clientX = 351 ,
16
+ clientY = 223 ,
17
+ gd ;
18
+
19
+ function click ( ) {
20
+ mouseEvent ( 'mousemove' , clientX , clientY ) ;
21
+ mouseEvent ( 'mousedown' , clientX , clientY ) ;
22
+ mouseEvent ( 'mouseup' , clientX , clientY ) ;
23
+ }
24
+
25
+ beforeEach ( function ( done ) {
26
+ gd = createGraphDiv ( ) ;
27
+
28
+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout )
29
+ . then ( done ) ;
30
+ } ) ;
31
+
32
+ it ( 'should contain the correct fields' , function ( ) {
33
+ var futureData ;
34
+
35
+ gd . on ( 'plotly_click' , function ( data ) {
36
+ futureData = data ;
29
37
} ) ;
30
38
31
- afterEach ( destroyGraphDiv ) ;
39
+ click ( ) ;
32
40
33
- it ( 'should contain the correct fields' , function ( ) {
34
- var futureData ;
41
+ expect ( futureData . points . length ) . toEqual ( 1 ) ;
35
42
36
- gd . on ( 'plotly_click' , function ( data ) {
37
- futureData = data ;
38
- } ) ;
43
+ var pt = futureData . points [ 0 ] ;
44
+ expect ( Object . keys ( pt ) ) . toEqual ( [
45
+ 'data' , 'fullData' , 'curveNumber' , 'pointNumber' ,
46
+ 'x' , 'y' , 'xaxis' , 'yaxis'
47
+ ] ) ;
48
+ expect ( pt . curveNumber ) . toEqual ( 0 ) ;
49
+ expect ( pt . pointNumber ) . toEqual ( 11 ) ;
50
+ expect ( pt . x ) . toEqual ( 0.125 ) ;
51
+ expect ( pt . y ) . toEqual ( 2.125 ) ;
52
+ } ) ;
39
53
40
- click ( ) ;
41
54
42
- expect ( futureData . points . length ) . toEqual ( 1 ) ;
43
55
44
- var pt = futureData . points [ 0 ] ;
45
- expect ( Object . keys ( pt ) ) . toEqual ( [
46
- 'data' , 'fullData' , 'curveNumber' , 'pointNumber' ,
47
- 'x' , 'y' , 'xaxis' , 'yaxis'
48
- ] ) ;
49
- expect ( pt . curveNumber ) . toEqual ( 0 ) ;
50
- expect ( pt . pointNumber ) . toEqual ( 11 ) ;
51
- expect ( pt . x ) . toEqual ( 0.125 ) ;
52
- expect ( pt . y ) . toEqual ( 2.125 ) ;
53
56
} ) ;
54
57
} ) ;
55
58
} ) ;
0 commit comments