@@ -414,7 +414,6 @@ describe('Test plot api', function() {
414
414
415
415
// make sure we didn't muck with gd.data if things failed!
416
416
expect ( gd ) . toEqual ( expected ) ;
417
-
418
417
} ) ;
419
418
420
419
it ( 'should throw an error when traces and newIndices arrays are unequal' , function ( ) {
@@ -454,7 +453,6 @@ describe('Test plot api', function() {
454
453
expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
455
454
expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
456
455
expect ( PlotlyInternal . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ 1 , 3 ] ) ;
457
-
458
456
} ) ;
459
457
460
458
it ( 'should work when newIndices has negative indices' , function ( ) {
@@ -465,7 +463,6 @@ describe('Test plot api', function() {
465
463
expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
466
464
expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
467
465
expect ( PlotlyInternal . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ - 3 , - 1 ] ) ;
468
-
469
466
} ) ;
470
467
471
468
it ( 'should work when newIndices is an integer' , function ( ) {
@@ -474,7 +471,21 @@ describe('Test plot api', function() {
474
471
expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
475
472
expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
476
473
expect ( PlotlyInternal . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 1 ] , [ 0 ] ) ;
474
+ } ) ;
475
+
476
+ it ( 'should work when adding an existing trace' , function ( ) {
477
+ Plotly . addTraces ( gd , gd . data [ 0 ] ) ;
478
+
479
+ expect ( gd . data . length ) . toEqual ( 3 ) ;
480
+ expect ( gd . data [ 0 ] ) . not . toBe ( gd . data [ 2 ] ) ;
481
+ } ) ;
482
+
483
+ it ( 'should work when duplicating the existing data' , function ( ) {
484
+ Plotly . addTraces ( gd , gd . data ) ;
477
485
486
+ expect ( gd . data . length ) . toEqual ( 4 ) ;
487
+ expect ( gd . data [ 0 ] ) . not . toBe ( gd . data [ 2 ] ) ;
488
+ expect ( gd . data [ 1 ] ) . not . toBe ( gd . data [ 3 ] ) ;
478
489
} ) ;
479
490
} ) ;
480
491
0 commit comments