diff --git a/js/test/mapviewmodel.test.js b/js/test/mapviewmodel.test.js
index 45ace46..a6a80b8 100644
--- a/js/test/mapviewmodel.test.js
+++ b/js/test/mapviewmodel.test.js
@@ -30,6 +30,7 @@ describe('MapViewModel tests', () => {
let vm;
let state;
let mapEl;
+ let menuButtonEl;
let mockApi;
let bounds;
let track;
@@ -38,9 +39,12 @@ describe('MapViewModel tests', () => {
beforeEach(() => {
const fixture = `
`;
document.body.insertAdjacentHTML('afterbegin', fixture);
mapEl = document.querySelector('#map-canvas');
+ const menuEl = document.querySelector('#menu-close');
+ menuButtonEl = menuEl.firstChild;
config.reinitialize();
config.mapApi = defaultApi;
lang.init(config);
@@ -51,7 +55,8 @@ describe('MapViewModel tests', () => {
'zoomToBounds': { /* ignored */ },
'zoomToExtent': { /* ignored */ },
'displayTrack': { /* ignored */ },
- 'clearMap': { /* ignored */ }
+ 'clearMap': { /* ignored */ },
+ 'updateSize': { /* ignored */ }
});
state = new uState();
vm = new MapViewModel(state);
@@ -77,6 +82,17 @@ describe('MapViewModel tests', () => {
expect(vm.api).toBe(null);
});
+ it('should initialize instance', () => {
+ // given
+ spyOn(vm, 'bindAll');
+ spyOn(vm, 'setObservers');
+ // when
+ vm.init();
+ // then
+ expect(vm.bindAll).toHaveBeenCalledTimes(1);
+ expect(vm.setObservers).toHaveBeenCalledTimes(1);
+ });
+
it('should load openlayers api and call onReady', (done) => {
// given
spyOn(vm, 'onReady');
@@ -183,6 +199,19 @@ describe('MapViewModel tests', () => {
}, 100);
});
+ it('should resize map on menu toggle', (done) => {
+ // given
+ vm.api = mockApi;
+ vm.bindAll();
+ // when
+ menuButtonEl.click();
+ // then
+ setTimeout(() => {
+ expect(mockApi.updateSize).toHaveBeenCalledTimes(1);
+ done();
+ }, 100);
+ });
+
it('should clear map when state current track is cleared', (done) => {
// given
vm.api = mockApi;