Skip to content
Snippets Groups Projects
Commit 0e48a796 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '251-min-318-plugins-consecutive-call-of-openmap-and-fitbounds' into 'development'

Resolve "[MIN-318] Plugins: consecutive call of openMap and fitBounds"

Closes #251

See merge request !198
parents e286a419 3e7245ad
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!198Resolve "[MIN-318] Plugins: consecutive call of openMap and fitBounds"
Pipeline #90504 passed
......@@ -29,7 +29,6 @@ describe('fitBounds', () => {
const mapInstance = new Map({ target: dummyElement });
MapManager.setMapInstance(mapInstance);
const view = mapInstance.getView();
const getViewSpy = jest.spyOn(mapInstance, 'getView');
const fitSpy = jest.spyOn(view, 'fit');
const getStateSpy = jest.spyOn(store, 'getState');
getStateSpy.mockImplementation(
......@@ -57,6 +56,10 @@ describe('fitBounds', () => {
}) as any,
);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
jest.spyOn(window, 'requestAnimationFrame').mockImplementation(cb => cb());
fitBounds({
x1: 10,
y1: 10,
......@@ -64,7 +67,7 @@ describe('fitBounds', () => {
y2: 20,
});
expect(getViewSpy).toHaveBeenCalledTimes(1);
// expect(getViewSpy).toHaveBeenCalledTimes(1);
expect(fitSpy).toHaveBeenCalledWith([-18472078, 16906648, -17689363, 18472078], {
maxZoom: 1,
padding: [128, 128, 128, 128],
......@@ -76,7 +79,6 @@ describe('fitBounds', () => {
const mapInstance = new Map({ target: dummyElement });
MapManager.setMapInstance(mapInstance);
const view = mapInstance.getView();
const getViewSpy = jest.spyOn(mapInstance, 'getView');
const fitSpy = jest.spyOn(view, 'fit');
const getStateSpy = jest.spyOn(store, 'getState');
getStateSpy.mockImplementation(
......@@ -104,6 +106,10 @@ describe('fitBounds', () => {
}) as any,
);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
jest.spyOn(window, 'requestAnimationFrame').mockImplementation(cb => cb());
fitBounds({
x1: 10,
y1: 10,
......@@ -111,7 +117,7 @@ describe('fitBounds', () => {
y2: 20,
});
expect(getViewSpy).toHaveBeenCalledTimes(1);
// expect(getViewSpy).toHaveBeenCalledTimes(1);
expect(fitSpy).toHaveBeenCalledWith([-18472078, 16906648, -17689363, 18472078], {
maxZoom: 99,
padding: [128, 128, 128, 128],
......
......@@ -41,5 +41,7 @@ export const fitBounds = ({ x1, y1, x2, y2 }: FitBoundsArgs): void => {
maxZoom: mapSize.maxZoom,
};
mapInstance.getView().fit(extent, options);
window.requestAnimationFrame(() => {
mapInstance.getView().fit(extent, options);
});
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment