Merge pull request #13915 from MoonE/fix-map-render-test

Fix map render test
This commit is contained in:
MoonE
2022-07-31 21:17:42 +02:00
committed by GitHub
+9 -18
View File
@@ -1070,41 +1070,32 @@ describe('ol/Map', function () {
expect(spy.callCount).to.be(0); expect(spy.callCount).to.be(0);
}); });
it('calls renderFrame_ and results in an postrender event', function (done) { it('calls renderFrame_ and results in a postrender event', function (done) {
const spy = sinon.spy(map, 'renderFrame_'); const spy = sinon.spy(map, 'renderFrame_');
map.render(); map.render();
map.once('postrender', function (event) { map.once('postrender', function (event) {
expect(event).to.be.a(MapEvent); expect(event).to.be.a(MapEvent);
expect(typeof spy.firstCall.args[0]).to.be('number'); expect(typeof spy.firstCall.args[0]).to.be('number');
spy.restore(); spy.restore();
const frameState = event.frameState; expect(event.frameState).not.to.be(null);
expect(frameState).not.to.be(null);
done(); done();
}); });
}); });
it('uses the same render frame for subsequent calls', function (done) { it('uses the same render frame for subsequent calls', function () {
map.render(); map.render();
const id1 = map.animationDelayKey_; const id1 = map.animationDelayKey_;
let id2 = null;
map.once('postrender', function () {
expect(id2).to.be(id1);
done();
});
map.render(); map.render();
id2 = map.animationDelayKey_; const id2 = map.animationDelayKey_;
expect(id1).to.be(id2);
}); });
it('creates a new render frame after renderSync()', function (done) { it('creates a new render frame after renderSync()', function () {
let id2 = null;
map.render(); map.render();
const id1 = map.animationDelayKey_; expect(map.animationDelayKey_).to.not.be(undefined);
map.once('postrender', function () {
expect(id2).to.not.be(id1);
done();
});
map.renderSync(); map.renderSync();
id2 = map.animationDelayKey_; expect(map.animationDelayKey_).to.be(undefined);
}); });
it('results in an postrender event (for zero height map)', function (done) { it('results in an postrender event (for zero height map)', function (done) {