@@ -414,7 +414,6 @@ describe('Test plot api', function() {
414414
415415 // make sure we didn't muck with gd.data if things failed!
416416 expect ( gd ) . toEqual ( expected ) ;
417-
418417 } ) ;
419418
420419 it ( 'should throw an error when traces and newIndices arrays are unequal' , function ( ) {
@@ -454,7 +453,6 @@ describe('Test plot api', function() {
454453 expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
455454 expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
456455 expect ( PlotlyInternal . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ 1 , 3 ] ) ;
457-
458456 } ) ;
459457
460458 it ( 'should work when newIndices has negative indices' , function ( ) {
@@ -465,7 +463,6 @@ describe('Test plot api', function() {
465463 expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
466464 expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
467465 expect ( PlotlyInternal . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ - 3 , - 1 ] ) ;
468-
469466 } ) ;
470467
471468 it ( 'should work when newIndices is an integer' , function ( ) {
@@ -474,7 +471,21 @@ describe('Test plot api', function() {
474471 expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
475472 expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
476473 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 ) ;
477485
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 ] ) ;
478489 } ) ;
479490 } ) ;
480491
0 commit comments