Skip to content
Snippets Groups Projects

Overlays additional rendering conditions

Merged Tadeusz Miesiąc requested to merge overlays-additional-rendering-conditions into development
2 unresolved threads
Files
24
 
import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore';
 
import { initialMapStateFixture } from '@/redux/map/map.fixtures';
 
import {
 
BACKGROUNDS_MOCK,
 
BACKGROUND_INITIAL_STATE_MOCK,
 
} from '@/redux/backgrounds/background.mock';
 
import { renderHook } from '@testing-library/react';
 
import { useEmptyBackground } from './useEmptyBackground';
 
 
const DEFAULT_BACKGROUND_ID = 0;
 
const EMPTY_BACKGROUND_ID = 15;
 
 
describe('useEmptyBackground - hook', () => {
 
describe('returns setEmptyBackground function', () => {
 
it('should not set background to "Empty" if its not available', () => {
 
const { Wrapper, store } = getReduxWrapperWithStore({
 
map: initialMapStateFixture,
 
backgrounds: BACKGROUND_INITIAL_STATE_MOCK,
 
});
 
const { result } = renderHook(() => useEmptyBackground(), { wrapper: Wrapper });
 
 
expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID);
 
 
result.current.setBackgroundtoEmptyIfAvailable();
 
 
expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID);
 
});
 
 
it('should set background to "Empty" if its available', () => {
 
const { Wrapper, store } = getReduxWrapperWithStore({
 
map: initialMapStateFixture,
 
backgrounds: { ...BACKGROUND_INITIAL_STATE_MOCK, data: BACKGROUNDS_MOCK },
 
});
 
const { result } = renderHook(() => useEmptyBackground(), { wrapper: Wrapper });
 
 
expect(store.getState().map.data.backgroundId).toBe(DEFAULT_BACKGROUND_ID);
 
 
result.current.setBackgroundtoEmptyIfAvailable();
 
 
expect(store.getState().map.data.backgroundId).toBe(EMPTY_BACKGROUND_ID);
 
});
 
});
 
});
Loading