Skip to content

Commit

Permalink
Add unit tests for ZoomToMaxExtentButton
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismayer committed Jun 27, 2018
1 parent 903909e commit fadbf77
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/unit/specs/maxextentbutton/ZoomToMaxExtentButton.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Vue from 'vue'
import ZoomToMaxExtentButton from '@/components/maxextentbutton/ZoomToMaxExtentButton'
import OlMap from 'ol/map';
import OlView from 'ol/view';

describe('maxextentbutton/ZoomToMaxExtentButton.vue', () => {
// Check methods
it('has a method onClick', () => {
const Constructor = Vue.extend(ZoomToMaxExtentButton);
const ztmeb = new Constructor({
}).$mount();
expect(typeof ztmeb.onClick).to.equal('function');
});

it('onClick sets correct center and zoom', () => {
const Constructor = Vue.extend(ZoomToMaxExtentButton);
const ztmeb = new Constructor({
}).$mount();

ztmeb.$appConfig = {
mapCenter: [0, 0],
mapZoom: 0
};
ztmeb.map = new OlMap({
view: new OlView({
center: [1, 1],
zoom: 1
})
});

ztmeb.onClick();
expect(ztmeb.map.getView().getCenter()[0]).to.equal(0);
expect(ztmeb.map.getView().getCenter()[1]).to.equal(0);
expect(ztmeb.map.getView().getZoom()).to.equal(0);
});
});

0 comments on commit fadbf77

Please sign in to comment.