@@ -12,26 +12,31 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
1212var delay = require ( '../assets/delay' ) ;
1313var mock = require ( '@mocks/animation' ) ;
1414
15- function runTests ( transitionDuration ) {
16- describe ( 'Plots.transition (duration = ' + transitionDuration + ')' , function ( ) {
17- 'use strict' ;
15+ describe ( 'Plots.transition' , function ( ) {
16+ 'use strict' ;
1817
19- var gd ;
18+ var gd ;
2019
21- beforeEach ( function ( done ) {
22- gd = createGraphDiv ( ) ;
20+ beforeEach ( function ( done ) {
21+ gd = createGraphDiv ( ) ;
2322
24- var mockCopy = Lib . extendDeep ( { } , mock ) ;
23+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
2524
26- Plotly . newPlot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
27- } ) ;
25+ Plotly . newPlot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
26+ } ) ;
2827
29- afterEach ( function ( ) {
30- Plotly . purge ( gd ) ;
31- destroyGraphDiv ( ) ;
32- } ) ;
28+ afterEach ( function ( ) {
29+ Plotly . purge ( gd ) ;
30+ destroyGraphDiv ( ) ;
31+ } ) ;
3332
34- it ( 'resolves only once the transition has completed' , function ( done ) {
33+ // Run the whole set of tests twice: once with zero duration and once with
34+ // nonzero duration since the behavior should be identical, but there's a
35+ // very real possibility of race conditions or other timing issues.
36+ //
37+ // And of course, remember to put the async loop in a closure:
38+ [ 0 , 20 ] . forEach ( function ( transitionDuration ) {
39+ it ( 'with duration:' + transitionDuration + ', resolves only once the transition has completed' , function ( done ) {
3540 var t1 = Date . now ( ) ;
3641 var traces = plotApiHelpers . coerceTraceIndices ( gd , null ) ;
3742
@@ -42,7 +47,7 @@ function runTests(transitionDuration) {
4247 } ) . then ( done , done . fail ) ;
4348 } ) ;
4449
45- it ( 'emits plotly_transitioning on transition start' , function ( done ) {
50+ it ( 'with duration:' + transitionDuration + ', emits plotly_transitioning on transition start', function ( done ) {
4651 var beginTransitionCnt = 0 ;
4752 var traces = plotApiHelpers . coerceTraceIndices ( gd , null ) ;
4853
@@ -55,7 +60,7 @@ function runTests(transitionDuration) {
5560 } ) . then ( done , done . fail ) ;
5661 } ) ;
5762
58- it ( 'emits plotly_transitioned on transition end' , function ( done ) {
63+ it ( 'with duration:' + transitionDuration + ', emits plotly_transitioned on transition end', function ( done ) {
5964 var trEndCnt = 0 ;
6065 var traces = plotApiHelpers . coerceTraceIndices ( gd , null ) ;
6166
@@ -68,7 +73,7 @@ function runTests(transitionDuration) {
6873 } ) . then ( done , done . fail ) ;
6974 } ) ;
7075
71- it ( 'transitions an annotation' , function ( done ) {
76+ it ( 'with duration:' + transitionDuration + ', transitions an annotation', function ( done ) {
7277 function annotationPosition ( ) {
7378 var g = gd . _fullLayout . _infolayer . select ( '.annotation' ) . select ( '.annotation-text-g' ) ;
7479 var bBox = g . node ( ) . getBoundingClientRect ( ) ;
@@ -96,7 +101,7 @@ function runTests(transitionDuration) {
96101 } ) . then ( done , done . fail ) ;
97102 } ) ;
98103
99- it ( 'transitions an image' , function ( done ) {
104+ it ( 'with duration:' + transitionDuration + ', transitions an image', function ( done ) {
100105 var jsLogo = 'https://images.plot.ly/language-icons/api-home/js-logo.png' ;
101106 var pythonLogo = 'https://images.plot.ly/language-icons/api-home/python-logo.png' ;
102107
@@ -131,7 +136,7 @@ function runTests(transitionDuration) {
131136 } ) . then ( done , done . fail ) ;
132137 } ) ;
133138
134- it ( 'transitions a shape' , function ( done ) {
139+ it ( 'with duration:' + transitionDuration + ', transitions a shape', function ( done ) {
135140 function getPath ( ) {
136141 return gd . _fullLayout . _shapeUpperLayer . select ( 'path' ) . node ( ) ;
137142 }
@@ -189,7 +194,7 @@ function runTests(transitionDuration) {
189194 } ) ;
190195
191196
192- it ( 'transitions a transform' , function ( done ) {
197+ it ( 'with duration:' + transitionDuration + ', transitions a transform', function ( done ) {
193198 Plotly . restyle ( gd , {
194199 'transforms[0]' : {
195200 enabled : true ,
@@ -226,7 +231,7 @@ function runTests(transitionDuration) {
226231
227232 // This doesn't really test anything that the above tests don't cover, but it combines
228233 // the behavior and attempts to ensure chaining and events happen in the correct order.
229- it ( 'transitions may be chained' , function ( done ) {
234+ it ( 'with duration:' + transitionDuration + ', transitions may be chained', function ( done ) {
230235 var currentlyRunning = 0 ;
231236 var beginCnt = 0 ;
232237 var endCnt = 0 ;
@@ -258,17 +263,8 @@ function runTests(transitionDuration) {
258263 . then ( done , done . fail ) ;
259264 } ) ;
260265 } ) ;
261- }
266+ } ) ;
262267
263- for ( var i = 0 ; i < 2 ; i ++ ) {
264- var duration = i * 20 ;
265- // Run the whole set of tests twice: once with zero duration and once with
266- // nonzero duration since the behavior should be identical, but there's a
267- // very real possibility of race conditions or other timing issues.
268- //
269- // And of course, remember to put the async loop in a closure:
270- runTests ( duration ) ;
271- }
272268
273269describe ( 'Plotly.react transitions:' , function ( ) {
274270 var gd ;
@@ -844,7 +840,7 @@ describe('Plotly.react transitions:', function() {
844840 . then ( done , done . fail ) ;
845841 } ) ;
846842
847- it ( 'should not transition layout when axis auto-ranged value do not changed' , function ( done ) {
843+ it ( '@flaky should not transition layout when axis auto-ranged value do not changed' , function ( done ) {
848844 var data = [ { y : [ 1 , 2 , 1 ] } ] ;
849845 var layout = { transition : { duration : 10 } } ;
850846
0 commit comments