@@ -12,26 +12,31 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
12
12
var delay = require ( '../assets/delay' ) ;
13
13
var mock = require ( '@mocks/animation' ) ;
14
14
15
- function runTests ( transitionDuration ) {
16
- describe ( 'Plots.transition (duration = ' + transitionDuration + ')' , function ( ) {
17
- 'use strict' ;
15
+ describe ( 'Plots.transition' , function ( ) {
16
+ 'use strict' ;
18
17
19
- var gd ;
18
+ var gd ;
20
19
21
- beforeEach ( function ( done ) {
22
- gd = createGraphDiv ( ) ;
20
+ beforeEach ( function ( done ) {
21
+ gd = createGraphDiv ( ) ;
23
22
24
- var mockCopy = Lib . extendDeep ( { } , mock ) ;
23
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
25
24
26
- Plotly . newPlot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
27
- } ) ;
25
+ Plotly . newPlot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
26
+ } ) ;
28
27
29
- afterEach ( function ( ) {
30
- Plotly . purge ( gd ) ;
31
- destroyGraphDiv ( ) ;
32
- } ) ;
28
+ afterEach ( function ( ) {
29
+ Plotly . purge ( gd ) ;
30
+ destroyGraphDiv ( ) ;
31
+ } ) ;
33
32
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 ) {
35
40
var t1 = Date . now ( ) ;
36
41
var traces = plotApiHelpers . coerceTraceIndices ( gd , null ) ;
37
42
@@ -42,7 +47,7 @@ function runTests(transitionDuration) {
42
47
} ) . then ( done , done . fail ) ;
43
48
} ) ;
44
49
45
- it ( 'emits plotly_transitioning on transition start' , function ( done ) {
50
+ it ( 'with duration:' + transitionDuration + ', emits plotly_transitioning on transition start', function ( done ) {
46
51
var beginTransitionCnt = 0 ;
47
52
var traces = plotApiHelpers . coerceTraceIndices ( gd , null ) ;
48
53
@@ -55,7 +60,7 @@ function runTests(transitionDuration) {
55
60
} ) . then ( done , done . fail ) ;
56
61
} ) ;
57
62
58
- it ( 'emits plotly_transitioned on transition end' , function ( done ) {
63
+ it ( 'with duration:' + transitionDuration + ', emits plotly_transitioned on transition end', function ( done ) {
59
64
var trEndCnt = 0 ;
60
65
var traces = plotApiHelpers . coerceTraceIndices ( gd , null ) ;
61
66
@@ -68,7 +73,7 @@ function runTests(transitionDuration) {
68
73
} ) . then ( done , done . fail ) ;
69
74
} ) ;
70
75
71
- it ( 'transitions an annotation' , function ( done ) {
76
+ it ( 'with duration:' + transitionDuration + ', transitions an annotation', function ( done ) {
72
77
function annotationPosition ( ) {
73
78
var g = gd . _fullLayout . _infolayer . select ( '.annotation' ) . select ( '.annotation-text-g' ) ;
74
79
var bBox = g . node ( ) . getBoundingClientRect ( ) ;
@@ -96,7 +101,7 @@ function runTests(transitionDuration) {
96
101
} ) . then ( done , done . fail ) ;
97
102
} ) ;
98
103
99
- it ( 'transitions an image' , function ( done ) {
104
+ it ( 'with duration:' + transitionDuration + ', transitions an image', function ( done ) {
100
105
var jsLogo = 'https://images.plot.ly/language-icons/api-home/js-logo.png' ;
101
106
var pythonLogo = 'https://images.plot.ly/language-icons/api-home/python-logo.png' ;
102
107
@@ -131,7 +136,7 @@ function runTests(transitionDuration) {
131
136
} ) . then ( done , done . fail ) ;
132
137
} ) ;
133
138
134
- it ( 'transitions a shape' , function ( done ) {
139
+ it ( 'with duration:' + transitionDuration + ', transitions a shape', function ( done ) {
135
140
function getPath ( ) {
136
141
return gd . _fullLayout . _shapeUpperLayer . select ( 'path' ) . node ( ) ;
137
142
}
@@ -189,7 +194,7 @@ function runTests(transitionDuration) {
189
194
} ) ;
190
195
191
196
192
- it ( 'transitions a transform' , function ( done ) {
197
+ it ( 'with duration:' + transitionDuration + ', transitions a transform', function ( done ) {
193
198
Plotly . restyle ( gd , {
194
199
'transforms[0]' : {
195
200
enabled : true ,
@@ -226,7 +231,7 @@ function runTests(transitionDuration) {
226
231
227
232
// This doesn't really test anything that the above tests don't cover, but it combines
228
233
// 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 ) {
230
235
var currentlyRunning = 0 ;
231
236
var beginCnt = 0 ;
232
237
var endCnt = 0 ;
@@ -258,17 +263,8 @@ function runTests(transitionDuration) {
258
263
. then ( done , done . fail ) ;
259
264
} ) ;
260
265
} ) ;
261
- }
266
+ } ) ;
262
267
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
- }
272
268
273
269
describe ( 'Plotly.react transitions:' , function ( ) {
274
270
var gd ;
@@ -844,7 +840,7 @@ describe('Plotly.react transitions:', function() {
844
840
. then ( done , done . fail ) ;
845
841
} ) ;
846
842
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 ) {
848
844
var data = [ { y : [ 1 , 2 , 1 ] } ] ;
849
845
var layout = { transition : { duration : 10 } } ;
850
846
0 commit comments