@@ -9,6 +9,7 @@ var Legend = require('@src/components/legend');
9
9
var Axes = require ( '@src/plots/cartesian/axes' ) ;
10
10
var pkg = require ( '../../../package.json' ) ;
11
11
var subroutines = require ( '@src/plot_api/subroutines' ) ;
12
+ var manageArrays = require ( '@src/plot_api/manage_arrays' ) ;
12
13
var helpers = require ( '@src/plot_api/helpers' ) ;
13
14
var editTypes = require ( '@src/plot_api/edit_types' ) ;
14
15
@@ -2674,6 +2675,10 @@ describe('Test plot api', function() {
2674
2675
} ) ;
2675
2676
2676
2677
beforeEach ( function ( done ) {
2678
+ Object . keys ( subroutines ) . forEach ( function ( k ) {
2679
+ subroutines [ k ] . calls . reset ( ) ;
2680
+ } ) ;
2681
+
2677
2682
gd = createGraphDiv ( ) ;
2678
2683
Plotly . plot ( gd , [ { y : [ 2 , 1 , 2 ] } ] ) . then ( function ( ) {
2679
2684
data = gd . data ;
@@ -2687,8 +2692,6 @@ describe('Test plot api', function() {
2687
2692
afterEach ( destroyGraphDiv ) ;
2688
2693
2689
2694
it ( 'call doTraceStyle on trace style updates' , function ( done ) {
2690
- expect ( subroutines . doTraceStyle ) . not . toHaveBeenCalled ( ) ;
2691
-
2692
2695
Plotly . update ( gd , { 'marker.color' : 'blue' } ) . then ( function ( ) {
2693
2696
expect ( subroutines . doTraceStyle ) . toHaveBeenCalledTimes ( 1 ) ;
2694
2697
expect ( calcdata ) . toBe ( gd . calcdata ) ;
@@ -2720,16 +2723,14 @@ describe('Test plot api', function() {
2720
2723
expect ( data ) . toBe ( gd . data ) ;
2721
2724
expect ( layout ) . toBe ( gd . layout ) ;
2722
2725
expect ( calcdata ) . not . toBe ( gd . calcdata ) ;
2723
-
2724
2726
expect ( gd . data . length ) . toEqual ( 1 ) ;
2727
+ expect ( subroutines . layoutReplot ) . toHaveBeenCalledTimes ( 1 ) ;
2725
2728
} )
2726
2729
. catch ( failTest )
2727
2730
. then ( done ) ;
2728
2731
} ) ;
2729
2732
2730
2733
it ( 'call doLegend on legend updates' , function ( done ) {
2731
- expect ( subroutines . doLegend ) . not . toHaveBeenCalled ( ) ;
2732
-
2733
2734
Plotly . update ( gd , { } , { 'showlegend' : true } ) . then ( function ( ) {
2734
2735
expect ( subroutines . doLegend ) . toHaveBeenCalledTimes ( 1 ) ;
2735
2736
expect ( calcdata ) . toBe ( gd . calcdata ) ;
@@ -2738,8 +2739,8 @@ describe('Test plot api', function() {
2738
2739
. then ( done ) ;
2739
2740
} ) ;
2740
2741
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 ( ) ;
2743
2744
2744
2745
var layoutUpdate = {
2745
2746
updatemenus : [ {
@@ -2751,16 +2752,15 @@ describe('Test plot api', function() {
2751
2752
} ;
2752
2753
2753
2754
Plotly . update ( gd , { } , layoutUpdate ) . then ( function ( ) {
2754
- expect ( subroutines . doLegend ) . toHaveBeenCalledTimes ( 1 ) ;
2755
+ expect ( manageArrays . applyContainerArrayChanges ) . toHaveBeenCalledTimes ( 1 ) ;
2756
+ expect ( subroutines . layoutReplot ) . toHaveBeenCalledTimes ( 0 ) ;
2755
2757
expect ( calcdata ) . toBe ( gd . calcdata ) ;
2756
2758
} )
2757
2759
. catch ( failTest )
2758
2760
. then ( done ) ;
2759
2761
} ) ;
2760
2762
2761
2763
it ( 'call doModeBar when updating \'dragmode\'' , function ( done ) {
2762
- expect ( subroutines . doModeBar ) . not . toHaveBeenCalled ( ) ;
2763
-
2764
2764
Plotly . update ( gd , { } , { 'dragmode' : 'pan' } ) . then ( function ( ) {
2765
2765
expect ( subroutines . doModeBar ) . toHaveBeenCalledTimes ( 1 ) ;
2766
2766
expect ( calcdata ) . toBe ( gd . calcdata ) ;
0 commit comments