Ensure that all animations complete

This commit is contained in:
Tim Schaub
2016-11-05 17:31:49 -06:00
parent 3d26d3bdc6
commit c452164b8a
3 changed files with 64 additions and 10 deletions

View File

@@ -301,6 +301,48 @@ describe('ol.View', function() {
});
describe('#animate()', function() {
var originalRequestAnimationFrame = window.requestAnimationFrame;
var originalCancelAnimationFrame = window.cancelAnimationFrame;
beforeEach(function() {
window.requestAnimationFrame = function(callback) {
return setTimeout(callback, 1);
};
window.cancelAnimationFrame = function(key) {
return clearTimeout(key);
};
});
afterEach(function() {
window.requestAnimationFrame = originalRequestAnimationFrame;
window.cancelAnimationFrame = originalCancelAnimationFrame;
});
it('can be called to animate view properties', function(done) {
var view = new ol.View({
center: [0, 0],
zoom: 5
});
view.animate({
zoom: 4,
duration: 25
});
expect(view.getAnimating()).to.eql(true);
setTimeout(function() {
expect(view.getCenter()).to.eql([0, 0]);
expect(view.getZoom()).to.eql(4);
expect(view.getAnimating()).to.eql(false);
done();
}, 50);
});
});
describe('#getResolutions', function() {
var view;
var resolutions = [512, 256, 128, 64, 32, 16];