Update test with map resize event
This commit is contained in:
parent
ceb8796590
commit
4492249f82
@ -30,6 +30,7 @@ describe('MapViewModel tests', () => {
|
|||||||
let vm;
|
let vm;
|
||||||
let state;
|
let state;
|
||||||
let mapEl;
|
let mapEl;
|
||||||
|
let menuButtonEl;
|
||||||
let mockApi;
|
let mockApi;
|
||||||
let bounds;
|
let bounds;
|
||||||
let track;
|
let track;
|
||||||
@ -38,9 +39,12 @@ describe('MapViewModel tests', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const fixture = `<div id="fixture">
|
const fixture = `<div id="fixture">
|
||||||
<div id="map-canvas"></div>
|
<div id="map-canvas"></div>
|
||||||
|
<div id="menu-close"><a data-bind="onMenuToggle"></a></div>
|
||||||
</div>`;
|
</div>`;
|
||||||
document.body.insertAdjacentHTML('afterbegin', fixture);
|
document.body.insertAdjacentHTML('afterbegin', fixture);
|
||||||
mapEl = document.querySelector('#map-canvas');
|
mapEl = document.querySelector('#map-canvas');
|
||||||
|
const menuEl = document.querySelector('#menu-close');
|
||||||
|
menuButtonEl = menuEl.firstChild;
|
||||||
config.reinitialize();
|
config.reinitialize();
|
||||||
config.mapApi = defaultApi;
|
config.mapApi = defaultApi;
|
||||||
lang.init(config);
|
lang.init(config);
|
||||||
@ -51,7 +55,8 @@ describe('MapViewModel tests', () => {
|
|||||||
'zoomToBounds': { /* ignored */ },
|
'zoomToBounds': { /* ignored */ },
|
||||||
'zoomToExtent': { /* ignored */ },
|
'zoomToExtent': { /* ignored */ },
|
||||||
'displayTrack': { /* ignored */ },
|
'displayTrack': { /* ignored */ },
|
||||||
'clearMap': { /* ignored */ }
|
'clearMap': { /* ignored */ },
|
||||||
|
'updateSize': { /* ignored */ }
|
||||||
});
|
});
|
||||||
state = new uState();
|
state = new uState();
|
||||||
vm = new MapViewModel(state);
|
vm = new MapViewModel(state);
|
||||||
@ -77,6 +82,17 @@ describe('MapViewModel tests', () => {
|
|||||||
expect(vm.api).toBe(null);
|
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) => {
|
it('should load openlayers api and call onReady', (done) => {
|
||||||
// given
|
// given
|
||||||
spyOn(vm, 'onReady');
|
spyOn(vm, 'onReady');
|
||||||
@ -183,6 +199,19 @@ describe('MapViewModel tests', () => {
|
|||||||
}, 100);
|
}, 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) => {
|
it('should clear map when state current track is cleared', (done) => {
|
||||||
// given
|
// given
|
||||||
vm.api = mockApi;
|
vm.api = mockApi;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user