@@ -9,47 +9,50 @@ var mouseEvent = require('../assets/mouse_event');
99describe ( 'click event' , function ( ) {
1010 var mock = require ( '@mocks/14.json' ) ;
1111
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 ;
2937 } ) ;
3038
31- afterEach ( destroyGraphDiv ) ;
39+ click ( ) ;
3240
33- it ( 'should contain the correct fields' , function ( ) {
34- var futureData ;
41+ expect ( futureData . points . length ) . toEqual ( 1 ) ;
3542
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+ } ) ;
3953
40- click ( ) ;
4154
42- expect ( futureData . points . length ) . toEqual ( 1 ) ;
4355
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 ) ;
5356 } ) ;
5457 } ) ;
5558} ) ;
0 commit comments