@@ -934,7 +934,7 @@ describe('Test plot api', function() {
934
934
} ) ;
935
935
936
936
describe ( 'Plotly.update should' , function ( ) {
937
- var gd , calcdata ;
937
+ var gd , data , layout , calcdata ;
938
938
939
939
beforeAll ( function ( ) {
940
940
Object . keys ( subroutines ) . forEach ( function ( k ) {
@@ -945,6 +945,8 @@ describe('Test plot api', function() {
945
945
beforeEach ( function ( done ) {
946
946
gd = createGraphDiv ( ) ;
947
947
Plotly . plot ( gd , [ { y : [ 2 , 1 , 2 ] } ] ) . then ( function ( ) {
948
+ data = gd . data ;
949
+ layout = gd . layout ;
948
950
calcdata = gd . calcdata ;
949
951
done ( ) ;
950
952
} ) ;
@@ -964,11 +966,33 @@ describe('Test plot api', function() {
964
966
965
967
it ( 'clear calcdata on data updates' , function ( done ) {
966
968
Plotly . update ( gd , { x : [ [ 3 , 1 , 3 ] ] } ) . then ( function ( ) {
969
+ expect ( data ) . toBe ( gd . data ) ;
970
+ expect ( layout ) . toBe ( gd . layout ) ;
967
971
expect ( calcdata ) . not . toBe ( gd . calcdata ) ;
968
972
done ( ) ;
969
973
} ) ;
970
974
} ) ;
971
975
976
+ it ( 'clear calcdata on data + axis updates w/o extending current gd.data' , function ( done ) {
977
+ var traceUpdate = {
978
+ x : [ [ 3 , 1 , 3 ] ]
979
+ } ;
980
+
981
+ var layoutUpdate = {
982
+ xaxis : { title : 'A' , type : '-' }
983
+ } ;
984
+
985
+ Plotly . update ( gd , traceUpdate , layoutUpdate ) . then ( function ( ) {
986
+ expect ( data ) . toBe ( gd . data ) ;
987
+ expect ( layout ) . toBe ( gd . layout ) ;
988
+ expect ( calcdata ) . not . toBe ( gd . calcdata ) ;
989
+
990
+ expect ( gd . data . length ) . toEqual ( 1 ) ;
991
+
992
+ done ( ) ;
993
+ } ) ;
994
+ } ) ;
995
+
972
996
it ( 'call doLegend on legend updates' , function ( done ) {
973
997
expect ( subroutines . doLegend ) . not . toHaveBeenCalled ( ) ;
974
998
0 commit comments