@@ -9,6 +9,7 @@ var Legend = require('@src/components/legend');
99var Axes = require ( '@src/plots/cartesian/axes' ) ;
1010var pkg = require ( '../../../package.json' ) ;
1111var subroutines = require ( '@src/plot_api/subroutines' ) ;
12+ var manageArrays = require ( '@src/plot_api/manage_arrays' ) ;
1213var helpers = require ( '@src/plot_api/helpers' ) ;
1314var editTypes = require ( '@src/plot_api/edit_types' ) ;
1415
@@ -2674,6 +2675,10 @@ describe('Test plot api', function() {
26742675 } ) ;
26752676
26762677 beforeEach ( function ( done ) {
2678+ Object . keys ( subroutines ) . forEach ( function ( k ) {
2679+ subroutines [ k ] . calls . reset ( ) ;
2680+ } ) ;
2681+
26772682 gd = createGraphDiv ( ) ;
26782683 Plotly . plot ( gd , [ { y : [ 2 , 1 , 2 ] } ] ) . then ( function ( ) {
26792684 data = gd . data ;
@@ -2687,8 +2692,6 @@ describe('Test plot api', function() {
26872692 afterEach ( destroyGraphDiv ) ;
26882693
26892694 it ( 'call doTraceStyle on trace style updates' , function ( done ) {
2690- expect ( subroutines . doTraceStyle ) . not . toHaveBeenCalled ( ) ;
2691-
26922695 Plotly . update ( gd , { 'marker.color' : 'blue' } ) . then ( function ( ) {
26932696 expect ( subroutines . doTraceStyle ) . toHaveBeenCalledTimes ( 1 ) ;
26942697 expect ( calcdata ) . toBe ( gd . calcdata ) ;
@@ -2720,16 +2723,14 @@ describe('Test plot api', function() {
27202723 expect ( data ) . toBe ( gd . data ) ;
27212724 expect ( layout ) . toBe ( gd . layout ) ;
27222725 expect ( calcdata ) . not . toBe ( gd . calcdata ) ;
2723-
27242726 expect ( gd . data . length ) . toEqual ( 1 ) ;
2727+ expect ( subroutines . layoutReplot ) . toHaveBeenCalledTimes ( 1 ) ;
27252728 } )
27262729 . catch ( failTest )
27272730 . then ( done ) ;
27282731 } ) ;
27292732
27302733 it ( 'call doLegend on legend updates' , function ( done ) {
2731- expect ( subroutines . doLegend ) . not . toHaveBeenCalled ( ) ;
2732-
27332734 Plotly . update ( gd , { } , { 'showlegend' : true } ) . then ( function ( ) {
27342735 expect ( subroutines . doLegend ) . toHaveBeenCalledTimes ( 1 ) ;
27352736 expect ( calcdata ) . toBe ( gd . calcdata ) ;
@@ -2738,8 +2739,8 @@ describe('Test plot api', function() {
27382739 . then ( done ) ;
27392740 } ) ;
27402741
2741- it ( 'call layoutReplot when adding update menu' , function ( done ) {
2742- expect ( subroutines . layoutReplot ) . not . toHaveBeenCalled ( ) ;
2742+ it ( 'call array manager when adding update menu' , function ( done ) {
2743+ spyOn ( manageArrays , 'applyContainerArrayChanges' ) . and . callThrough ( ) ;
27432744
27442745 var layoutUpdate = {
27452746 updatemenus : [ {
@@ -2751,16 +2752,15 @@ describe('Test plot api', function() {
27512752 } ;
27522753
27532754 Plotly . update ( gd , { } , layoutUpdate ) . then ( function ( ) {
2754- expect ( subroutines . doLegend ) . toHaveBeenCalledTimes ( 1 ) ;
2755+ expect ( manageArrays . applyContainerArrayChanges ) . toHaveBeenCalledTimes ( 1 ) ;
2756+ expect ( subroutines . layoutReplot ) . toHaveBeenCalledTimes ( 0 ) ;
27552757 expect ( calcdata ) . toBe ( gd . calcdata ) ;
27562758 } )
27572759 . catch ( failTest )
27582760 . then ( done ) ;
27592761 } ) ;
27602762
27612763 it ( 'call doModeBar when updating \'dragmode\'' , function ( done ) {
2762- expect ( subroutines . doModeBar ) . not . toHaveBeenCalled ( ) ;
2763-
27642764 Plotly . update ( gd , { } , { 'dragmode' : 'pan' } ) . then ( function ( ) {
27652765 expect ( subroutines . doModeBar ) . toHaveBeenCalledTimes ( 1 ) ;
27662766 expect ( calcdata ) . toBe ( gd . calcdata ) ;
0 commit comments