@@ -809,11 +809,48 @@ describe('@gl Test gl2d plots', function() {
809809 var scene = gd . _fullLayout . _plots . xy . _scene ;
810810
811811 expect ( scene . count ) . toBe ( 2 ) ;
812- expect ( scene . selectBatch ) . toBeDefined ( ) ;
813- expect ( scene . unselectBatch ) . toBeDefined ( ) ;
812+ expect ( scene . selectBatch ) . toEqual ( [ [ 0 ] ] ) ;
813+ expect ( scene . unselectBatch ) . toEqual ( [ [ ] ] ) ;
814814 expect ( scene . markerOptions . length ) . toBe ( 2 ) ;
815815 expect ( scene . markerOptions [ 1 ] . color ) . toEqual ( new Uint8Array ( [ 255 , 0 , 0 , 255 ] ) ) ;
816816 expect ( scene . scatter2d . draw ) . toHaveBeenCalled ( ) ;
817+
818+ return Plotly . restyle ( gd , 'selectedpoints' , null ) ;
819+ } )
820+ . then ( function ( ) {
821+ var scene = gd . _fullLayout . _plots . xy . _scene ;
822+ var msg = 'clearing under dragmode select' ;
823+
824+ expect ( scene . selectBatch ) . toEqual ( [ ] , msg ) ;
825+ expect ( scene . unselectBatch ) . toEqual ( [ ] , msg ) ;
826+
827+ // scattergl uses different pathways for select/lasso & zoom/pan
828+ return Plotly . relayout ( gd , 'dragmode' , 'pan' ) ;
829+ } )
830+ . then ( function ( ) {
831+ var scene = gd . _fullLayout . _plots . xy . _scene ;
832+ var msg = 'cleared under dragmode pan' ;
833+
834+ expect ( scene . selectBatch ) . toEqual ( [ ] , msg ) ;
835+ expect ( scene . unselectBatch ) . toEqual ( [ ] , msg ) ;
836+
837+ return Plotly . restyle ( gd , 'selectedpoints' , [ [ 1 , 2 ] , [ 0 ] ] ) ;
838+ } )
839+ . then ( function ( ) {
840+ var scene = gd . _fullLayout . _plots . xy . _scene ;
841+ var msg = 'selecting via API under dragmode pan' ;
842+
843+ expect ( scene . selectBatch ) . toEqual ( [ [ 1 , 2 ] , [ 0 ] ] , msg ) ;
844+ expect ( scene . unselectBatch ) . toEqual ( [ [ 0 ] , [ ] ] , msg ) ;
845+
846+ return Plotly . restyle ( gd , 'selectedpoints' , null ) ;
847+ } )
848+ . then ( function ( ) {
849+ var scene = gd . _fullLayout . _plots . xy . _scene ;
850+ var msg = 'clearing under dragmode pan' ;
851+
852+ expect ( scene . selectBatch ) . toBe ( null , msg ) ;
853+ expect ( scene . unselectBatch ) . toBe ( null , msg ) ;
817854 } )
818855 . catch ( fail )
819856 . then ( done ) ;
0 commit comments