From 903909e6f910cf976d6be4c9f776cbb2dea0930c Mon Sep 17 00:00:00 2001 From: Christian Mayer Date: Wed, 27 Jun 2018 14:58:57 +0200 Subject: [PATCH 1/2] Add ZoomToMaxExtentButton component --- src/WguApp.vue | 9 ++++- .../maxextentbutton/ZoomToMaxExtentButton.vue | 40 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/components/maxextentbutton/ZoomToMaxExtentButton.vue diff --git a/src/WguApp.vue b/src/WguApp.vue index d98198c8..8c6b048b 100644 --- a/src/WguApp.vue +++ b/src/WguApp.vue @@ -5,6 +5,11 @@ + + + +
+ + + {{icon}} + {{text}} + + +
+ + + + + + + From fadbf7774cae95bc2d99a836ee76247b7d110872 Mon Sep 17 00:00:00 2001 From: Christian Mayer Date: Wed, 27 Jun 2018 15:18:35 +0200 Subject: [PATCH 2/2] Add unit tests for ZoomToMaxExtentButton --- .../ZoomToMaxExtentButton.spec.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/unit/specs/maxextentbutton/ZoomToMaxExtentButton.spec.js diff --git a/test/unit/specs/maxextentbutton/ZoomToMaxExtentButton.spec.js b/test/unit/specs/maxextentbutton/ZoomToMaxExtentButton.spec.js new file mode 100644 index 00000000..279eb2e6 --- /dev/null +++ b/test/unit/specs/maxextentbutton/ZoomToMaxExtentButton.spec.js @@ -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); + }); +});