@@ -16,7 +16,7 @@ describe('select box and lasso', function() {
16
16
var selectPath = [ [ 93 , 193 ] , [ 143 , 193 ] ] ;
17
17
var lassoPath = [ [ 316 , 171 ] , [ 318 , 239 ] , [ 335 , 243 ] , [ 328 , 169 ] ] ;
18
18
19
- beforeEach ( function ( ) {
19
+ beforeAll ( function ( ) {
20
20
jasmine . addMatchers ( customMatchers ) ;
21
21
} ) ;
22
22
@@ -59,6 +59,13 @@ describe('select box and lasso', function() {
59
59
} ) ;
60
60
}
61
61
62
+ function assertSelectionNodes ( cornerCnt , outlineCnt ) {
63
+ expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
64
+ . toBe ( cornerCnt , 'selection corner count' ) ;
65
+ expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
66
+ . toBe ( outlineCnt , 'selection outline count' ) ;
67
+ }
68
+
62
69
describe ( 'select elements' , function ( ) {
63
70
var mockCopy = Lib . extendDeep ( { } , mock ) ;
64
71
mockCopy . layout . dragmode = 'select' ;
@@ -80,30 +87,21 @@ describe('select box and lasso', function() {
80
87
y2 = 50 ;
81
88
82
89
gd . once ( 'plotly_selecting' , function ( ) {
83
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
84
- . toEqual ( 1 ) ;
85
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
86
- . toEqual ( 2 ) ;
90
+ assertSelectionNodes ( 1 , 2 ) ;
87
91
} ) ;
88
92
89
93
gd . once ( 'plotly_selected' , function ( ) {
90
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
91
- . toEqual ( 0 ) ;
92
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
93
- . toEqual ( 2 ) ;
94
+ assertSelectionNodes ( 0 , 2 ) ;
94
95
} ) ;
95
96
96
97
gd . once ( 'plotly_deselect' , function ( ) {
97
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
98
- . toEqual ( 0 ) ;
98
+ assertSelectionNodes ( 0 , 0 ) ;
99
99
} ) ;
100
100
101
101
mouseEvent ( 'mousemove' , x0 , y0 ) ;
102
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
103
- . toEqual ( 0 ) ;
102
+ assertSelectionNodes ( 0 , 0 ) ;
104
103
105
104
drag ( [ [ x0 , y0 ] , [ x1 , y1 ] ] ) ;
106
-
107
105
doubleClick ( x2 , y2 ) . then ( done ) ;
108
106
} ) ;
109
107
} ) ;
@@ -129,30 +127,21 @@ describe('select box and lasso', function() {
129
127
y2 = 50 ;
130
128
131
129
gd . once ( 'plotly_selecting' , function ( ) {
132
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
133
- . toEqual ( 1 ) ;
134
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
135
- . toEqual ( 2 ) ;
130
+ assertSelectionNodes ( 1 , 2 ) ;
136
131
} ) ;
137
132
138
133
gd . once ( 'plotly_selected' , function ( ) {
139
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
140
- . toEqual ( 0 ) ;
141
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
142
- . toEqual ( 2 ) ;
134
+ assertSelectionNodes ( 0 , 2 ) ;
143
135
} ) ;
144
136
145
137
gd . once ( 'plotly_deselect' , function ( ) {
146
- expect ( d3 . selectAll ( '.zoomlayer > .select-outline' ) . size ( ) )
147
- . toEqual ( 0 ) ;
138
+ assertSelectionNodes ( 0 , 0 ) ;
148
139
} ) ;
149
140
150
141
mouseEvent ( 'mousemove' , x0 , y0 ) ;
151
- expect ( d3 . selectAll ( '.zoomlayer > .zoombox-corners' ) . size ( ) )
152
- . toEqual ( 0 ) ;
142
+ assertSelectionNodes ( 0 , 0 ) ;
153
143
154
144
drag ( [ [ x0 , y0 ] , [ x1 , y1 ] ] ) ;
155
-
156
145
doubleClick ( x2 , y2 ) . then ( done ) ;
157
146
} ) ;
158
147
} ) ;
0 commit comments