@@ -6,6 +6,7 @@ var Lib = require('@src/lib');
6
6
7
7
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
8
8
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
9
+ var failTest = require ( '../assets/fail_test' ) ;
9
10
var customAssertions = require ( '../assets/custom_assertions' ) ;
10
11
var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
11
12
@@ -434,9 +435,9 @@ describe('multiple transforms:', function() {
434
435
expect ( gd . _fullData [ 0 ] . transforms [ 0 ] . _indexToPoints ) . toEqual ( { 0 : [ 1 ] , 1 : [ 3 ] , 2 : [ 4 ] } ) ;
435
436
expect ( gd . _fullData [ 0 ] . transforms [ 1 ] . _indexToPoints ) . toEqual ( { 0 : [ 1 , 3 ] , 1 : [ 4 ] } ) ;
436
437
expect ( gd . _fullData [ 0 ] . transforms [ 2 ] . _indexToPoints ) . toEqual ( { 0 : [ 4 ] } ) ;
437
-
438
- done ( ) ;
439
- } ) ;
438
+ } )
439
+ . catch ( failTest )
440
+ . then ( done ) ;
440
441
} ) ;
441
442
442
443
@@ -455,9 +456,9 @@ describe('multiple transforms:', function() {
455
456
expect ( gd . _fullData [ 1 ] . y ) . toEqual ( [ 2 , 3 ] ) ;
456
457
457
458
assertDims ( [ 2 , 2 ] ) ;
458
-
459
- done ( ) ;
460
- } ) ;
459
+ } )
460
+ . catch ( failTest )
461
+ . then ( done ) ;
461
462
} ) ;
462
463
463
464
it ( 'Plotly.plot should plot the transform traces (reverse case)' , function ( done ) {
@@ -477,9 +478,9 @@ describe('multiple transforms:', function() {
477
478
expect ( gd . _fullData [ 1 ] . y ) . toEqual ( [ 2 , 3 ] ) ;
478
479
479
480
assertDims ( [ 2 , 2 ] ) ;
480
-
481
- done ( ) ;
482
- } ) ;
481
+ } )
482
+ . catch ( failTest )
483
+ . then ( done ) ;
483
484
} ) ;
484
485
485
486
it ( 'Plotly.restyle should work' , function ( done ) {
@@ -529,9 +530,9 @@ describe('multiple transforms:', function() {
529
530
[ 'rgb(0, 128, 0)' , 'rgb(255, 0, 0)' ] ,
530
531
[ 0.4 , 0.4 ]
531
532
) ;
532
-
533
- done ( ) ;
534
- } ) ;
533
+ } )
534
+ . catch ( failTest )
535
+ . then ( done ) ;
535
536
} ) ;
536
537
537
538
it ( 'Plotly.extendTraces should work' , function ( done ) {
@@ -573,9 +574,9 @@ describe('multiple transforms:', function() {
573
574
return Plotly . deleteTraces ( gd , [ 0 ] ) ;
574
575
} ) . then ( function ( ) {
575
576
assertDims ( [ ] ) ;
576
-
577
- done ( ) ;
578
- } ) ;
577
+ } )
578
+ . catch ( failTest )
579
+ . then ( done ) ;
579
580
} ) ;
580
581
581
582
it ( 'toggling trace visibility should work' , function ( done ) {
@@ -595,12 +596,12 @@ describe('multiple transforms:', function() {
595
596
return Plotly . restyle ( gd , 'visible' , [ true , true ] ) ;
596
597
} ) . then ( function ( ) {
597
598
assertDims ( [ 2 , 2 , 2 , 2 ] ) ;
598
-
599
- done ( ) ;
600
- } ) ;
599
+ } )
600
+ . catch ( failTest )
601
+ . then ( done ) ;
601
602
} ) ;
602
603
603
- it ( 'executes filter and aggregate in the order given' , function ( ) {
604
+ it ( 'executes filter and aggregate in the order given' , function ( done ) {
604
605
// filter and aggregate do not commute!
605
606
606
607
var trace1 = {
@@ -624,18 +625,21 @@ describe('multiple transforms:', function() {
624
625
var trace2 = Lib . extendDeep ( { } , trace1 ) ;
625
626
trace2 . transforms . reverse ( ) ;
626
627
627
- Plotly . newPlot ( gd , [ trace1 , trace2 ] ) ;
628
+ Plotly . newPlot ( gd , [ trace1 , trace2 ] ) . then ( function ( ) {
629
+ var trace1Out = gd . _fullData [ 0 ] ;
630
+ expect ( trace1Out . x ) . toEqual ( [ 2 ] ) ;
631
+ expect ( trace1Out . y ) . toEqual ( [ 5 ] ) ;
628
632
629
- var trace1Out = gd . _fullData [ 0 ] ;
630
- expect ( trace1Out . x ) . toEqual ( [ 2 ] ) ;
631
- expect ( trace1Out . y ) . toEqual ( [ 5 ] ) ;
633
+ var trace2Out = gd . _fullData [ 1 ] ;
634
+ expect ( trace2Out . x ) . toEqual ( [ 4 , - 5 ] ) ;
635
+ expect ( trace2Out . y ) . toEqual ( [ 5 , 4 ] ) ;
632
636
633
- var trace2Out = gd . _fullData [ 1 ] ;
634
- expect ( trace2Out . x ) . toEqual ( [ 4 , - 5 ] ) ;
635
- expect ( trace2Out . y ) . toEqual ( [ 5 , 4 ] ) ;
637
+ } )
638
+ . catch ( failTest )
639
+ . then ( done ) ;
636
640
} ) ;
637
641
638
- it ( 'always executes groupby before aggregate' , function ( ) {
642
+ it ( 'always executes groupby before aggregate' , function ( done ) {
639
643
// aggregate and groupby wouldn't commute, but groupby always happens first
640
644
// because it has a `transform`, and aggregate has a `calcTransform`
641
645
@@ -658,29 +662,31 @@ describe('multiple transforms:', function() {
658
662
var trace2 = Lib . extendDeep ( { } , trace1 ) ;
659
663
trace2 . transforms . reverse ( ) ;
660
664
661
- Plotly . newPlot ( gd , [ trace1 , trace2 ] ) ;
662
-
663
- var t1g1 = gd . _fullData [ 0 ] ;
664
- var t1g2 = gd . _fullData [ 1 ] ;
665
- var t2g1 = gd . _fullData [ 2 ] ;
666
- var t2g2 = gd . _fullData [ 3 ] ;
667
-
668
- expect ( t1g1 . x ) . toEqual ( [ 1 , 2 ] ) ;
669
- expect ( t1g1 . y ) . toEqual ( [ 2 , 4 ] ) ;
670
- // group 2 has its aggregations switched, since group 2 comes first
671
- expect ( t1g2 . x ) . toEqual ( [ 3 , 9 ] ) ;
672
- expect ( t1g2 . y ) . toEqual ( [ 6 , 9 ] ) ;
673
-
674
- // if we had done aggregation first, we'd implicitly get the first val
675
- // for each of the groupby groups, which is [1, 1]
676
- // so we'd only make 1 output trace, and it would look like:
677
- // {x: [10, 5], y: [20/3, 5]}
678
- // (and if we got some other groupby groups values, the most it could do
679
- // is break ^^ into two separate traces)
680
- expect ( t2g1 . x ) . toEqual ( t1g1 . x ) ;
681
- expect ( t2g1 . y ) . toEqual ( t1g1 . y ) ;
682
- expect ( t2g2 . x ) . toEqual ( t1g2 . x ) ;
683
- expect ( t2g2 . y ) . toEqual ( t1g2 . y ) ;
665
+ Plotly . newPlot ( gd , [ trace1 , trace2 ] ) . then ( function ( ) {
666
+ var t1g1 = gd . _fullData [ 0 ] ;
667
+ var t1g2 = gd . _fullData [ 1 ] ;
668
+ var t2g1 = gd . _fullData [ 2 ] ;
669
+ var t2g2 = gd . _fullData [ 3 ] ;
670
+
671
+ expect ( t1g1 . x ) . toEqual ( [ 1 , 2 ] ) ;
672
+ expect ( t1g1 . y ) . toEqual ( [ 2 , 4 ] ) ;
673
+ // group 2 has its aggregations switched, since group 2 comes first
674
+ expect ( t1g2 . x ) . toEqual ( [ 3 , 9 ] ) ;
675
+ expect ( t1g2 . y ) . toEqual ( [ 6 , 9 ] ) ;
676
+
677
+ // if we had done aggregation first, we'd implicitly get the first val
678
+ // for each of the groupby groups, which is [1, 1]
679
+ // so we'd only make 1 output trace, and it would look like:
680
+ // {x: [10, 5], y: [20/3, 5]}
681
+ // (and if we got some other groupby groups values, the most it could do
682
+ // is break ^^ into two separate traces)
683
+ expect ( t2g1 . x ) . toEqual ( t1g1 . x ) ;
684
+ expect ( t2g1 . y ) . toEqual ( t1g1 . y ) ;
685
+ expect ( t2g2 . x ) . toEqual ( t1g2 . x ) ;
686
+ expect ( t2g2 . y ) . toEqual ( t1g2 . y ) ;
687
+ } )
688
+ . catch ( failTest )
689
+ . then ( done ) ;
684
690
} ) ;
685
691
} ) ;
686
692
@@ -699,8 +705,9 @@ describe('invalid transforms', function() {
699
705
transforms : [ { } ]
700
706
} ] ) . then ( function ( ) {
701
707
expect ( gd . _fullData [ 0 ] . transforms . length ) . toEqual ( 1 ) ;
702
- done ( ) ;
703
- } ) ;
708
+ } )
709
+ . catch ( failTest )
710
+ . then ( done ) ;
704
711
} ) ;
705
712
} ) ;
706
713
@@ -761,9 +768,9 @@ describe('multiple traces with transforms:', function() {
761
768
expect ( gd . _fullData [ 2 ] . y ) . toEqual ( [ 3 , 5 , 2 ] ) ;
762
769
763
770
assertDims ( [ 2 , 3 , 3 ] ) ;
764
-
765
- done ( ) ;
766
- } ) ;
771
+ } )
772
+ . catch ( failTest )
773
+ . then ( done ) ;
767
774
} ) ;
768
775
769
776
it ( 'Plotly.restyle should work' , function ( done ) {
@@ -816,9 +823,9 @@ describe('multiple traces with transforms:', function() {
816
823
[ 'rgb(0, 128, 0)' , 'rgb(0, 128, 0)' , 'rgb(255, 0, 0)' ] ,
817
824
[ 0.4 , 0.6 , 0.6 ]
818
825
) ;
819
-
820
- done ( ) ;
821
- } ) ;
826
+ } )
827
+ . catch ( failTest )
828
+ . then ( done ) ;
822
829
} ) ;
823
830
824
831
it ( 'Plotly.extendTraces should work' , function ( done ) {
@@ -843,9 +850,9 @@ describe('multiple traces with transforms:', function() {
843
850
} , [ 0 ] ) ;
844
851
} ) . then ( function ( ) {
845
852
assertDims ( [ 5 , 4 , 4 ] ) ;
846
-
847
- done ( ) ;
848
- } ) ;
853
+ } )
854
+ . catch ( failTest )
855
+ . then ( done ) ;
849
856
} ) ;
850
857
851
858
it ( 'Plotly.deleteTraces should work' , function ( done ) {
@@ -863,9 +870,9 @@ describe('multiple traces with transforms:', function() {
863
870
return Plotly . deleteTraces ( gd , [ 0 ] ) ;
864
871
} ) . then ( function ( ) {
865
872
assertDims ( [ ] ) ;
866
-
867
- done ( ) ;
868
- } ) ;
873
+ } )
874
+ . catch ( failTest )
875
+ . then ( done ) ;
869
876
} ) ;
870
877
871
878
it ( 'toggling trace visibility should work' , function ( done ) {
@@ -891,9 +898,10 @@ describe('multiple traces with transforms:', function() {
891
898
return Plotly . restyle ( gd , 'visible' , 'legendonly' , [ 0 ] ) ;
892
899
} ) . then ( function ( ) {
893
900
assertDims ( [ 3 , 3 ] ) ;
901
+ } )
902
+ . catch ( failTest )
903
+ . then ( done ) ;
894
904
895
- done ( ) ;
896
- } ) ;
897
905
} ) ;
898
906
} ) ;
899
907
@@ -959,6 +967,7 @@ describe('restyle applied on transforms:', function() {
959
967
expect ( gd . data [ 0 ] . transforms ) . toBeUndefined ( msg ) ;
960
968
expect ( gd . _fullData [ 0 ] . y ) . toEqual ( [ 2 , 1 , 2 ] , msg ) ;
961
969
} )
970
+ . catch ( failTest )
962
971
. then ( done ) ;
963
972
} ) ;
964
973
0 commit comments