Separate internal and API methods for the view

This commit is contained in:
Tim Schaub
2019-08-11 17:28:28 -06:00
parent f73d0b16ec
commit c03c359a20
17 changed files with 214 additions and 69 deletions

View File

@@ -78,7 +78,7 @@ describe('ol.interaction.DragZoom', function() {
interaction.onBoxEnd_();
setTimeout(function() {
const view = map.getView();
const center = view.getCenter();
const center = view.getCenterInternal();
expect(center).to.eql(getCenter(extent));
done();
}, 50);

View File

@@ -24,7 +24,7 @@ describe('ol.interaction.KeyboardPan', function() {
describe('handleEvent()', function() {
it('pans on arrow keys', function() {
const view = map.getView();
const spy = sinon.spy(view, 'animate_');
const spy = sinon.spy(view, 'animateInternal');
const event = new MapBrowserEvent('keydown', map, {
type: 'keydown',
target: map.getTargetElement(),
@@ -51,7 +51,7 @@ describe('ol.interaction.KeyboardPan', function() {
expect(spy.getCall(3).args[0].center).to.eql([128, 0]);
view.setCenter([0, 0]);
view.animate_.restore();
view.animateInternal.restore();
});
});

View File

@@ -24,7 +24,7 @@ describe('ol.interaction.KeyboardZoom', function() {
describe('handleEvent()', function() {
it('zooms on + and - keys', function() {
const view = map.getView();
const spy = sinon.spy(view, 'animate');
const spy = sinon.spy(view, 'animateInternal');
const event = new MapBrowserEvent('keydown', map, {
type: 'keydown',
target: map.getTargetElement(),
@@ -41,7 +41,7 @@ describe('ol.interaction.KeyboardZoom', function() {
expect(spy.getCall(1).args[0].resolution).to.eql(4);
view.setResolution(2);
view.animate.restore();
view.animateInternal.restore();
});
});

View File

@@ -99,20 +99,20 @@ describe('ol.interaction.MouseWheelZoom', function() {
});
}
describe('spying on view.animate()', function() {
describe('spying on view.animateInternal()', function() {
let view;
beforeEach(function() {
view = map.getView();
sinon.spy(view, 'animate');
sinon.spy(view, 'animateInternal');
});
afterEach(function() {
view.animate.restore();
view.animateInternal.restore();
});
it('works in DOM_DELTA_LINE mode (wheel)', function(done) {
map.once('postrender', function() {
const call = view.animate.getCall(0);
const call = view.animateInternal.getCall(0);
expect(call.args[0].resolution).to.be(2);
expect(call.args[0].anchor).to.eql([0, 0]);
done();
@@ -132,7 +132,7 @@ describe('ol.interaction.MouseWheelZoom', function() {
it('works on all browsers (wheel)', function(done) {
map.once('postrender', function() {
const call = view.animate.getCall(0);
const call = view.animateInternal.getCall(0);
expect(call.args[0].resolution).to.be(2);
expect(call.args[0].anchor).to.eql([0, 0]);
done();