-
Adrian Orłów authoredAdrian Orłów authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
setZoom.test.ts 789 B
/* eslint-disable no-magic-numbers */
import { setLastPositionZoom } from '@/redux/map/map.slice';
import { store } from '@/redux/store';
import { ZodError } from 'zod';
import { setZoom } from './setZoom';
jest.mock('../../../../redux/store');
describe('setZoom - plugin method', () => {
const dispatchSpy = jest.spyOn(store, 'dispatch');
describe('when zoom is invalid', () => {
const invalidZoom = [-1, -123, '-123'] as number[];
it.each(invalidZoom)('should throw error', zoom => {
expect(() => setZoom(zoom)).toThrow(ZodError);
});
});
describe('when zoom is valid', () => {
const zoom = 2;
it('should set map zoom', () => {
setZoom(zoom);
expect(dispatchSpy).toHaveBeenCalledWith(setLastPositionZoom({ zoom }));
});
});
});