@@ -68,28 +68,40 @@ describe('select box and lasso', function() {
68
68
. then ( done ) ;
69
69
} ) ;
70
70
71
- it ( 'should be appended to the zoom layer' , function ( ) {
72
- var x0 = 100 ;
73
- var y0 = 200 ;
74
- var x1 = 150 ;
75
- var y1 = 200 ;
71
+ it ( 'should be appended to the zoom layer' , function ( done ) {
72
+ var x0 = 100 ,
73
+ y0 = 200 ,
74
+ x1 = 150 ,
75
+ y1 = 250 ,
76
+ x2 = 50 ,
77
+ y2 = 50 ;
78
+
79
+ gd . once ( 'plotly_selecting' , function ( ) {
80
+ expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
81
+ . toEqual ( 1 ) ;
82
+ expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
83
+ . toEqual ( 2 ) ;
84
+ } ) ;
85
+
86
+ gd . once ( 'plotly_selected' , function ( ) {
87
+ expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
88
+ . toEqual ( 0 ) ;
89
+ expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
90
+ . toEqual ( 2 ) ;
91
+ } ) ;
92
+
93
+ gd . once ( 'plotly_deselect' , function ( ) {
94
+ expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
95
+ . toEqual ( 0 ) ;
96
+ } ) ;
76
97
77
98
mouseEvent ( 'mousemove' , x0 , y0 ) ;
78
99
expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
79
100
. toEqual ( 0 ) ;
80
101
81
- mouseEvent ( 'mousedown' , x0 , y0 ) ;
82
- mouseEvent ( 'mousemove' , x1 , y1 ) ;
83
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
84
- . toEqual ( 1 ) ;
85
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
86
- . toEqual ( 2 ) ;
102
+ drag ( [ [ x0 , y0 ] , [ x1 , y1 ] ] ) ;
87
103
88
- mouseEvent ( 'mouseup' , x1 , y1 ) ;
89
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
90
- . toEqual ( 0 ) ;
91
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
92
- . toEqual ( 2 ) ;
104
+ doubleClick ( x2 , y2 , done ) ;
93
105
} ) ;
94
106
} ) ;
95
107
@@ -105,28 +117,40 @@ describe('select box and lasso', function() {
105
117
. then ( done ) ;
106
118
} ) ;
107
119
108
- it ( 'should be appended to the zoom layer' , function ( ) {
109
- var x0 = 100 ;
110
- var y0 = 200 ;
111
- var x1 = 150 ;
112
- var y1 = 200 ;
120
+ it ( 'should be appended to the zoom layer' , function ( done ) {
121
+ var x0 = 100 ,
122
+ y0 = 200 ,
123
+ x1 = 150 ,
124
+ y1 = 250 ,
125
+ x2 = 50 ,
126
+ y2 = 50 ;
127
+
128
+ gd . once ( 'plotly_selecting' , function ( ) {
129
+ expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
130
+ . toEqual ( 1 ) ;
131
+ expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
132
+ . toEqual ( 2 ) ;
133
+ } ) ;
134
+
135
+ gd . once ( 'plotly_selected' , function ( ) {
136
+ expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
137
+ . toEqual ( 0 ) ;
138
+ expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
139
+ . toEqual ( 2 ) ;
140
+ } ) ;
141
+
142
+ gd . once ( 'plotly_deselect' , function ( ) {
143
+ expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
144
+ . toEqual ( 0 ) ;
145
+ } ) ;
113
146
114
147
mouseEvent ( 'mousemove' , x0 , y0 ) ;
115
148
expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
116
149
. toEqual ( 0 ) ;
117
150
118
- mouseEvent ( 'mousedown' , x0 , y0 ) ;
119
- mouseEvent ( 'mousemove' , x1 , y1 ) ;
120
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
121
- . toEqual ( 1 ) ;
122
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
123
- . toEqual ( 2 ) ;
151
+ drag ( [ [ x0 , y0 ] , [ x1 , y1 ] ] ) ;
124
152
125
- mouseEvent ( 'mouseup' , x1 , y1 ) ;
126
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
127
- . toEqual ( 0 ) ;
128
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
129
- . toEqual ( 2 ) ;
153
+ doubleClick ( x2 , y2 , done ) ;
130
154
} ) ;
131
155
} ) ;
132
156
0 commit comments