Ensure that all animations complete
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user