Skip to content
Snippets Groups Projects

Feat/open submap bioentity

Merged Mateusz Bolewski requested to merge feat/open-submap-bioentity into development
3 unresolved threads
Files
4
/* eslint-disable no-magic-numbers */
import { act, render, screen } from '@testing-library/react';
import { StoreType } from '@/redux/store';
import { bioEntitiesContentFixture } from '@/models/fixtures/bioEntityContentsFixture';
@@ -5,9 +6,13 @@ import {
InitialStoreState,
getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore';
import { MODELS_MOCK_SHORT } from '@/models/mocks/modelsMock';
import { drawerSearchStepOneFixture } from '@/redux/drawer/drawerFixture';
import { initialMapDataFixture, openedMapsInitialValueFixture } from '@/redux/map/map.fixtures';
import { BioEntitiesSubmapItem } from './BioEntitiesSubmapItem.component';
const CORE_MAP_ID = 5053;
const SECOND_STEP = 2;
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
@@ -17,7 +22,8 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St
render(
<Wrapper>
<BioEntitiesSubmapItem
mapName="main map"
mapName={MODELS_MOCK_SHORT[0].name}
mapId={MODELS_MOCK_SHORT[0].idObject}
numberOfEntities={21}
bioEntities={bioEntitiesContentFixture}
/>
@@ -33,7 +39,7 @@ describe('BioEntitiesSubmapItem - component', () => {
it('should display map name, number of elements, icon', () => {
renderComponent();
expect(screen.getByText('main map (21)')).toBeInTheDocument();
expect(screen.getByText('Core PD map (21)')).toBeInTheDocument();
expect(screen.getByTestId('arrow-icon')).toBeInTheDocument();
});
it('should navigate user to bio enitites results list after clicking button', async () => {
@@ -69,4 +75,58 @@ describe('BioEntitiesSubmapItem - component', () => {
expect(currentStep).toBe(SECOND_STEP);
expect(listOfBioEnitites).toBe(bioEntitiesContentFixture);
});
it("should open submap and set it to active if it's not already opened", async () => {
const { store } = renderComponent({
bioEntity: {
data: [
{
searchQueryElement: '',
loading: 'succeeded',
error: { name: '', message: '' },
data: bioEntitiesContentFixture,
},
],
loading: 'succeeded',
error: { name: '', message: '' },
},
drawer: drawerSearchStepOneFixture,
models: { data: MODELS_MOCK_SHORT, loading: 'succeeded', error: { name: '', message: '' } },
map: {
data: initialMapDataFixture,
loading: 'succeeded',
error: { name: '', message: '' },
openedMaps: openedMapsInitialValueFixture,
},
});
const {
data: { modelId },
openedMaps,
} = store.getState().map;
expect(modelId).toBe(0);
expect(openedMaps).not.toContainEqual({
modelId: CORE_MAP_ID,
modelName: 'Core PD map',
lastPosition: { x: 0, y: 0, z: 0 },
});
const navigationButton = screen.getByTestId('bio-entites-submap-button');
await act(() => {
navigationButton.click();
});
const {
data: { modelId: newModelId },
openedMaps: newOpenedMaps,
} = store.getState().map;
expect(newOpenedMaps).toContainEqual({
modelId: CORE_MAP_ID,
modelName: 'Core PD map',
lastPosition: { x: 0, y: 0, z: 0 },
});
expect(newModelId).toBe(CORE_MAP_ID);
});
});
Loading