@@ -96,13 +96,16 @@ function assertEventCounts(selecting, selected, deselect, msg) {
9696 expect ( deselectCnt ) . toBe ( deselect , 'plotly_deselect call count: ' + msg ) ;
9797}
9898
99+ // TODO: in v2, when we get rid of the `plotly_selected->undefined` event, these will
100+ // change to BOXEVENTS = [1, 1, 1], LASSOEVENTS = [4, 1, 1]. See also _run down below
101+ //
99102// events for box or lasso select mouse moves then a doubleclick
100103var NOEVENTS = [ 0 , 0 , 0 ] ;
101104// deselect used to give an extra plotly_selected event on the first click
102105// with undefined event data - but now that's gone, since `clickFn` handles this.
103- var BOXEVENTS = [ 1 , 1 , 1 ] ;
106+ var BOXEVENTS = [ 1 , 2 , 1 ] ;
104107// assumes 5 points in the lasso path
105- var LASSOEVENTS = [ 4 , 1 , 1 ] ;
108+ var LASSOEVENTS = [ 4 , 2 , 1 ] ;
106109
107110describe ( 'Test select box and lasso in general:' , function ( ) {
108111 var mock = require ( '@mocks/14.json' ) ;
@@ -643,7 +646,11 @@ describe('Test select box and lasso per trace:', function() {
643646 return ( eventCounts [ 0 ] ? selectedPromise : Promise . resolve ( ) )
644647 . then ( afterDragFn )
645648 . then ( function ( ) {
646- assertEventCounts ( eventCounts [ 0 ] , eventCounts [ 1 ] , 0 , msg + ' (before dblclick)' ) ;
649+ // TODO: in v2 when we remove the `plotly_selecting->undefined` the Math.max(...)
650+ // in the middle here will turn into just eventCounts[1].
651+ // It's just here because one of the selected events is generated during
652+ // doubleclick so hasn't happened yet when we're testing this.
653+ assertEventCounts ( eventCounts [ 0 ] , Math . max ( 0 , eventCounts [ 1 ] - 1 ) , 0 , msg + ' (before dblclick)' ) ;
647654 return doubleClick ( dblClickPos [ 0 ] , dblClickPos [ 1 ] ) ;
648655 } )
649656 . then ( eventCounts [ 2 ] ? deselectPromise : Promise . resolve ( ) )
0 commit comments