@@ -560,14 +560,16 @@ describe('Test plot api', function() {
560
560
done ( ) ;
561
561
} ) ;
562
562
563
- Plotly . relayout ( gd , {
563
+ return Plotly . relayout ( gd , {
564
564
'title' : 'Plotly chart' ,
565
565
'xaxis.title' : 'X' ,
566
566
'xaxis.titlefont' : { color : 'green' } ,
567
567
'yaxis.title' : 'Y' ,
568
568
'polar.radialaxis.title' : 'Radial'
569
569
} ) ;
570
- } ) ;
570
+ } )
571
+ . catch ( failTest )
572
+ . then ( done ) ;
571
573
} ) ;
572
574
} ) ;
573
575
@@ -620,7 +622,7 @@ describe('Test plot api', function() {
620
622
expect ( subroutines . layoutReplot . calls . count ( ) ) . toBeGreaterThan ( 0 , msg ) ;
621
623
}
622
624
623
- it ( 'should trigger replot (but not recalc) when switching into select or lasso dragmode for scattergl traces' , function ( ) {
625
+ it ( 'should trigger replot (but not recalc) when switching into select or lasso dragmode for scattergl traces' , function ( done ) {
624
626
gd = mock ( {
625
627
data : [ {
626
628
type : 'scattergl' ,
@@ -660,7 +662,9 @@ describe('Test plot api', function() {
660
662
} )
661
663
. then ( function ( ) {
662
664
expectReplot ( 'select 2' ) ;
663
- } ) ;
665
+ } )
666
+ . catch ( failTest )
667
+ . then ( done ) ;
664
668
} ) ;
665
669
666
670
it ( 'should trigger replot (but not recalc) when changing attributes that affect axis length/range' , function ( ) {
@@ -755,7 +759,7 @@ describe('Test plot api', function() {
755
759
} ) ;
756
760
} ) ;
757
761
758
- it ( 'should trigger calc on axis range updates when constraints are present' , function ( ) {
762
+ it ( 'should trigger calc on axis range updates when constraints are present' , function ( done ) {
759
763
gd = mock ( {
760
764
data : [ {
761
765
y : [ 1 , 2 , 1 ]
@@ -769,7 +773,9 @@ describe('Test plot api', function() {
769
773
Plotly . relayout ( gd , 'xaxis.range[0]' , 0 )
770
774
. then ( function ( ) {
771
775
expect ( gd . calcdata ) . toBeUndefined ( ) ;
772
- } ) ;
776
+ } )
777
+ . catch ( failTest )
778
+ . then ( done ) ;
773
779
} ) ;
774
780
} ) ;
775
781
@@ -791,7 +797,7 @@ describe('Test plot api', function() {
791
797
gd . emit = function ( ) { } ;
792
798
}
793
799
794
- it ( 'calls Scatter.arraysToCalcdata and Plots.style on scatter styling' , function ( ) {
800
+ it ( 'calls Scatter.arraysToCalcdata and Plots.style on scatter styling' , function ( done ) {
795
801
var gd = {
796
802
data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ,
797
803
layout : { }
@@ -805,10 +811,12 @@ describe('Test plot api', function() {
805
811
expect ( plotApi . plot ) . not . toHaveBeenCalled ( ) ;
806
812
// "docalc" deletes gd.calcdata - make sure this didn't happen
807
813
expect ( gd . calcdata ) . toBeDefined ( ) ;
808
- } ) ;
814
+ } )
815
+ . catch ( failTest )
816
+ . then ( done ) ;
809
817
} ) ;
810
818
811
- it ( 'calls Bar.arraysToCalcdata and Plots.style on bar styling' , function ( ) {
819
+ it ( 'calls Bar.arraysToCalcdata and Plots.style on bar styling' , function ( done ) {
812
820
var gd = {
813
821
data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] , type : 'bar' } ] ,
814
822
layout : { }
@@ -821,10 +829,12 @@ describe('Test plot api', function() {
821
829
expect ( Plots . style ) . toHaveBeenCalled ( ) ;
822
830
expect ( plotApi . plot ) . not . toHaveBeenCalled ( ) ;
823
831
expect ( gd . calcdata ) . toBeDefined ( ) ;
824
- } ) ;
832
+ } )
833
+ . catch ( failTest )
834
+ . then ( done ) ;
825
835
} ) ;
826
836
827
- it ( 'should do full replot when arrayOk attributes are updated' , function ( ) {
837
+ it ( 'should do full replot when arrayOk attributes are updated' , function ( done ) {
828
838
var gd = {
829
839
data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ,
830
840
layout : { }
@@ -859,10 +869,12 @@ describe('Test plot api', function() {
859
869
. then ( function ( ) {
860
870
expect ( gd . calcdata ) . toBeUndefined ( ) ;
861
871
expect ( plotApi . plot ) . toHaveBeenCalled ( ) ;
862
- } ) ;
872
+ } )
873
+ . catch ( failTest )
874
+ . then ( done ) ;
863
875
} ) ;
864
876
865
- it ( 'should do full replot when arrayOk base attributes are updated' , function ( ) {
877
+ it ( 'should do full replot when arrayOk base attributes are updated' , function ( done ) {
866
878
var gd = {
867
879
data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ,
868
880
layout : { }
@@ -897,10 +909,12 @@ describe('Test plot api', function() {
897
909
. then ( function ( ) {
898
910
expect ( gd . calcdata ) . toBeUndefined ( ) ;
899
911
expect ( plotApi . plot ) . toHaveBeenCalled ( ) ;
900
- } ) ;
912
+ } )
913
+ . catch ( failTest )
914
+ . then ( done ) ;
901
915
} ) ;
902
916
903
- it ( 'should do full replot when attribute container are updated' , function ( ) {
917
+ it ( 'should do full replot when attribute container are updated' , function ( done ) {
904
918
var gd = {
905
919
data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ] ,
906
920
layout : {
@@ -918,10 +932,12 @@ describe('Test plot api', function() {
918
932
. then ( function ( ) {
919
933
expect ( gd . calcdata ) . toBeUndefined ( ) ;
920
934
expect ( plotApi . plot ) . toHaveBeenCalled ( ) ;
921
- } ) ;
935
+ } )
936
+ . catch ( failTest )
937
+ . then ( done ) ;
922
938
} ) ;
923
939
924
- it ( 'calls plot on xgap and ygap styling' , function ( ) {
940
+ it ( 'calls plot on xgap and ygap styling' , function ( done ) {
925
941
var gd = {
926
942
data : [ { z : [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] , showscale : false , type : 'heatmap' } ] ,
927
943
layout : { }
@@ -936,28 +952,27 @@ describe('Test plot api', function() {
936
952
} )
937
953
. then ( function ( ) {
938
954
expect ( plotApi . plot . calls . count ( ) ) . toEqual ( 2 ) ;
939
- } ) ;
955
+ } )
956
+ . catch ( failTest )
957
+ . then ( done ) ;
940
958
} ) ;
941
959
942
- it ( 'should clear calcdata when restyling \'zmin\' and \'zmax\' on contour traces' , function ( ) {
943
- var contour = {
960
+ [
961
+ {
944
962
data : [ {
945
963
type : 'contour' ,
946
964
z : [ [ 1 , 2 , 3 ] , [ 1 , 2 , 1 ] ]
947
965
} ]
948
- } ;
949
-
950
- var histogram2dcontour = {
966
+ } ,
967
+ {
951
968
data : [ {
952
969
type : 'histogram2dcontour' ,
953
970
x : [ 1 , 1 , 2 , 2 , 2 , 3 ] ,
954
971
y : [ 0 , 0 , 0 , 0 , 1 , 3 ]
955
972
} ]
956
- } ;
957
-
958
- var mocks = [ contour , histogram2dcontour ] ;
959
-
960
- mocks . forEach ( function ( gd ) {
973
+ }
974
+ ] . forEach ( function ( gd ) {
975
+ it ( 'should clear calcdata when restyling \'zmin\' and \'zmax\' on ' + gd . data . type + ' traces' , function ( done ) {
961
976
mockDefaultsAndCalc ( gd ) ;
962
977
plotApi . plot . calls . reset ( ) ;
963
978
Plotly . restyle ( gd , 'zmin' , 0 )
@@ -972,29 +987,28 @@ describe('Test plot api', function() {
972
987
. then ( function ( ) {
973
988
expect ( gd . calcdata ) . toBeUndefined ( ) ;
974
989
expect ( plotApi . plot ) . toHaveBeenCalled ( ) ;
975
- } ) ;
990
+ } )
991
+ . catch ( failTest )
992
+ . then ( done ) ;
976
993
} ) ;
977
994
} ) ;
978
995
979
- it ( 'should not clear calcdata when restyling \'zmin\' and \'zmax\' on heatmap traces' , function ( ) {
980
- var heatmap = {
996
+ [
997
+ {
981
998
data : [ {
982
999
type : 'heatmap' ,
983
1000
z : [ [ 1 , 2 , 3 ] , [ 1 , 2 , 1 ] ]
984
1001
} ]
985
- } ;
986
-
987
- var histogram2d = {
1002
+ } ,
1003
+ {
988
1004
data : [ {
989
1005
type : 'histogram2d' ,
990
1006
x : [ 1 , 1 , 2 , 2 , 2 , 3 ] ,
991
1007
y : [ 0 , 0 , 0 , 0 , 1 , 3 ]
992
1008
} ]
993
- } ;
994
-
995
- var mocks = [ heatmap , histogram2d ] ;
996
-
997
- mocks . forEach ( function ( gd ) {
1009
+ }
1010
+ ] . forEach ( function ( gd ) {
1011
+ it ( 'should not clear calcdata when restyling \'zmin\' and \'zmax\' on ' + gd . data . type + ' traces' , function ( done ) {
998
1012
mockDefaultsAndCalc ( gd ) ;
999
1013
plotApi . plot . calls . reset ( ) ;
1000
1014
Plotly . restyle ( gd , 'zmin' , 0 )
@@ -1009,11 +1023,17 @@ describe('Test plot api', function() {
1009
1023
. then ( function ( ) {
1010
1024
expect ( gd . calcdata ) . toBeDefined ( ) ;
1011
1025
expect ( plotApi . plot ) . toHaveBeenCalled ( ) ;
1012
- } ) ;
1026
+
1027
+ mockDefaultsAndCalc ( gd ) ;
1028
+ plotApi . plot . calls . reset ( ) ;
1029
+ return Plotly . restyle ( gd , 'zmin' , 0 ) ;
1030
+ } )
1031
+ . catch ( failTest )
1032
+ . then ( done ) ;
1013
1033
} ) ;
1014
1034
} ) ;
1015
1035
1016
- it ( 'ignores undefined values' , function ( ) {
1036
+ it ( 'ignores undefined values' , function ( done ) {
1017
1037
var gd = {
1018
1038
data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] , type : 'scatter' } ] ,
1019
1039
layout : { }
@@ -1031,10 +1051,12 @@ describe('Test plot api', function() {
1031
1051
} )
1032
1052
. then ( function ( ) {
1033
1053
expect ( gd . _fullData [ 0 ] . marker . color ) . toBe ( 'blue' ) ;
1034
- } ) ;
1054
+ } )
1055
+ . catch ( failTest )
1056
+ . then ( done ) ;
1035
1057
} ) ;
1036
1058
1037
- it ( 'ignores invalid trace indices' , function ( ) {
1059
+ it ( 'ignores invalid trace indices' , function ( done ) {
1038
1060
var gd = {
1039
1061
data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] , type : 'scatter' } ] ,
1040
1062
layout : { }
@@ -1043,10 +1065,12 @@ describe('Test plot api', function() {
1043
1065
mockDefaultsAndCalc ( gd ) ;
1044
1066
1045
1067
// Call restyle on an invalid trace indice
1046
- Plotly . restyle ( gd , { 'type' : 'scatter' , 'marker.color' : 'red' } , [ 1 ] ) ;
1068
+ Plotly . restyle ( gd , { 'type' : 'scatter' , 'marker.color' : 'red' } , [ 1 ] )
1069
+ . catch ( failTest )
1070
+ . then ( done ) ;
1047
1071
} ) ;
1048
1072
1049
- it ( 'restores null values to defaults' , function ( ) {
1073
+ it ( 'restores null values to defaults' , function ( done ) {
1050
1074
var gd = {
1051
1075
data : [ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] , type : 'scatter' } ] ,
1052
1076
layout : { }
@@ -1065,10 +1089,12 @@ describe('Test plot api', function() {
1065
1089
} )
1066
1090
. then ( function ( ) {
1067
1091
expect ( gd . _fullData [ 0 ] . marker . color ) . toBe ( colorDflt ) ;
1068
- } ) ;
1092
+ } )
1093
+ . catch ( failTest )
1094
+ . then ( done ) ;
1069
1095
} ) ;
1070
1096
1071
- it ( 'can target specific traces by leaving properties undefined' , function ( ) {
1097
+ it ( 'can target specific traces by leaving properties undefined' , function ( done ) {
1072
1098
var gd = {
1073
1099
data : [
1074
1100
{ x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] , type : 'scatter' } ,
@@ -1092,7 +1118,9 @@ describe('Test plot api', function() {
1092
1118
. then ( function ( ) {
1093
1119
expect ( gd . _fullData [ 0 ] . marker . color ) . toBe ( colorDflt [ 0 ] ) ;
1094
1120
expect ( gd . _fullData [ 1 ] . marker . color ) . toBe ( colorDflt [ 1 ] ) ;
1095
- } ) ;
1121
+ } )
1122
+ . catch ( failTest )
1123
+ . then ( done ) ;
1096
1124
} ) ;
1097
1125
} ) ;
1098
1126
0 commit comments