@@ -482,7 +482,7 @@ test('set({ showRecticle, recticleColor })', async t => {
482482
483483/* ---------------------------------- events -------------------------------- */
484484
485- test ( 'click selection with publish("select")' , async t => {
485+ test ( 'draw(), clear(), publish("select")' , async t => {
486486 const dim = 200 ;
487487 const hdim = dim / 2 ;
488488 const canvas = createCanvas ( dim , dim ) ;
@@ -496,6 +496,11 @@ test('click selection with publish("select")', async t => {
496496 [ - 1 , 1 ]
497497 ] ;
498498 scatterplot . draw ( points ) ;
499+ // The second draw call should not block the drawing of the points!
500+ // This test is related to a previous issue caused by `drawRaf` as `withRaf`
501+ // overwrites previous arguments. While that is normally expected, this
502+ // should not overwrite the points from above
503+ scatterplot . draw ( ) ;
499504
500505 // TODO: fix this!
501506 await wait ( 250 ) ;
@@ -514,13 +519,13 @@ test('click selection with publish("select")', async t => {
514519 window . dispatchEvent ( createMouseEvent ( 'mousedown' , hdim , hdim ) ) ;
515520 canvas . dispatchEvent ( createMouseEvent ( 'click' , hdim , hdim ) ) ;
516521
517- t . equal ( selectedPoints . length , 1 , 'should have selected 1 point' ) ;
522+ t . equal ( selectedPoints . length , 1 , 'should have selected one point' ) ;
518523 t . equal ( selectedPoints [ 0 ] , 0 , 'should have selected the first point' ) ;
519524
520525 // Test deselection
521526 canvas . dispatchEvent ( createMouseEvent ( 'dblclick' , hdim , hdim ) ) ;
522527
523- t . equal ( selectedPoints . length , 0 , 'should have deselected 1 point' ) ;
528+ t . equal ( selectedPoints . length , 0 , 'should have deselected one point' ) ;
524529
525530 // Test that mousedown + mousemove + click is not interpreted as a click when
526531 // the cursor moved more than `LASSO_MIN_DIST` in between mousedown and
@@ -530,7 +535,15 @@ test('click selection with publish("select")', async t => {
530535 ) ;
531536 canvas . dispatchEvent ( createMouseEvent ( 'click' , hdim , hdim ) ) ;
532537
533- t . equal ( selectedPoints . length , 0 , 'should *not* have selected 1 point' ) ;
538+ t . equal ( selectedPoints . length , 0 , 'should *not* have selected one point' ) ;
539+
540+ // Test that clearing the points works. The selection that worked previously
541+ // should not work anymore
542+ scatterplot . clear ( ) ;
543+ window . dispatchEvent ( createMouseEvent ( 'mousedown' , hdim , hdim ) ) ;
544+ canvas . dispatchEvent ( createMouseEvent ( 'click' , hdim , hdim ) ) ;
545+
546+ t . equal ( selectedPoints . length , 0 , 'should *not* have selected one point' ) ;
534547} ) ;
535548
536549test ( 'lasso selection with publish("select")' , async t => {
0 commit comments