Skip to content

Commit bc903cc

Browse files
committed
make one descibe block and use transition duration in test descriptions
1 parent bb351c8 commit bc903cc

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

test/jasmine/tests/transition_test.js

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,31 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
1212
var delay = require('../assets/delay');
1313
var mock = require('@mocks/animation');
1414

15-
[0, 20].forEach(function(transitionDuration) {
16-
// Run the whole set of tests twice: once with zero duration and once with
17-
// nonzero duration since the behavior should be identical, but there's a
18-
// very real possibility of race conditions or other timing issues.
19-
//
20-
// And of course, remember to put the async loop in a closure:
15+
describe('Plots.transition', function() {
16+
'use strict';
2117

22-
describe('Plots.transition (duration = ' + transitionDuration + ')', function() {
23-
'use strict';
24-
25-
var gd;
18+
var gd;
2619

27-
beforeEach(function(done) {
28-
gd = createGraphDiv();
20+
beforeEach(function(done) {
21+
gd = createGraphDiv();
2922

30-
var mockCopy = Lib.extendDeep({}, mock);
23+
var mockCopy = Lib.extendDeep({}, mock);
3124

32-
Plotly.newPlot(gd, mockCopy.data, mockCopy.layout).then(done);
33-
});
25+
Plotly.newPlot(gd, mockCopy.data, mockCopy.layout).then(done);
26+
});
3427

35-
afterEach(function() {
36-
Plotly.purge(gd);
37-
destroyGraphDiv();
38-
});
28+
afterEach(function() {
29+
Plotly.purge(gd);
30+
destroyGraphDiv();
31+
});
3932

40-
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) {
4140
var t1 = Date.now();
4241
var traces = plotApiHelpers.coerceTraceIndices(gd, null);
4342

@@ -48,7 +47,7 @@ var mock = require('@mocks/animation');
4847
}).then(done, done.fail);
4948
});
5049

51-
it('emits plotly_transitioning on transition start', function(done) {
50+
it('with duration:' + transitionDuration + ', emits plotly_transitioning on transition start', function(done) {
5251
var beginTransitionCnt = 0;
5352
var traces = plotApiHelpers.coerceTraceIndices(gd, null);
5453

@@ -61,7 +60,7 @@ var mock = require('@mocks/animation');
6160
}).then(done, done.fail);
6261
});
6362

64-
it('emits plotly_transitioned on transition end', function(done) {
63+
it('with duration:' + transitionDuration + ', emits plotly_transitioned on transition end', function(done) {
6564
var trEndCnt = 0;
6665
var traces = plotApiHelpers.coerceTraceIndices(gd, null);
6766

@@ -74,7 +73,7 @@ var mock = require('@mocks/animation');
7473
}).then(done, done.fail);
7574
});
7675

77-
it('transitions an annotation', function(done) {
76+
it('with duration:' + transitionDuration + ', transitions an annotation', function(done) {
7877
function annotationPosition() {
7978
var g = gd._fullLayout._infolayer.select('.annotation').select('.annotation-text-g');
8079
var bBox = g.node().getBoundingClientRect();
@@ -102,7 +101,7 @@ var mock = require('@mocks/animation');
102101
}).then(done, done.fail);
103102
});
104103

105-
it('transitions an image', function(done) {
104+
it('with duration:' + transitionDuration + ', transitions an image', function(done) {
106105
var jsLogo = 'https://images.plot.ly/language-icons/api-home/js-logo.png';
107106
var pythonLogo = 'https://images.plot.ly/language-icons/api-home/python-logo.png';
108107

@@ -137,7 +136,7 @@ var mock = require('@mocks/animation');
137136
}).then(done, done.fail);
138137
});
139138

140-
it('transitions a shape', function(done) {
139+
it('with duration:' + transitionDuration + ', transitions a shape', function(done) {
141140
function getPath() {
142141
return gd._fullLayout._shapeUpperLayer.select('path').node();
143142
}
@@ -195,7 +194,7 @@ var mock = require('@mocks/animation');
195194
});
196195

197196

198-
it('transitions a transform', function(done) {
197+
it('with duration:' + transitionDuration + ', transitions a transform', function(done) {
199198
Plotly.restyle(gd, {
200199
'transforms[0]': {
201200
enabled: true,
@@ -232,7 +231,7 @@ var mock = require('@mocks/animation');
232231

233232
// This doesn't really test anything that the above tests don't cover, but it combines
234233
// the behavior and attempts to ensure chaining and events happen in the correct order.
235-
it('transitions may be chained', function(done) {
234+
it('with duration:' + transitionDuration + ', transitions may be chained', function(done) {
236235
var currentlyRunning = 0;
237236
var beginCnt = 0;
238237
var endCnt = 0;

0 commit comments

Comments
 (0)