Skip to content
Snippets Groups Projects
Commit 7e6d4efe authored by Tadeusz Miesiąc's avatar Tadeusz Miesiąc
Browse files

test(useoverlayfeatures): added missing tests

parent 1d75a364
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...,!96fix(overlays): fixed opacity for overlays generated by entity color
Pipeline #84488 passed
/* eslint-disable no-magic-numbers */
import { renderHook } from '@testing-library/react';
import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore';
import { CONFIGURATION_INITIAL_STORE_MOCKS } from '@/redux/configuration/configuration.mock';
import { OVERLAYS_PUBLIC_FETCHED_STATE_MOCK } from '@/redux/overlays/overlays.mock';
import { mapStateWithCurrentlySelectedMainMapFixture } from '@/redux/map/map.fixtures';
import { MODELS_DATA_MOCK_WITH_MAIN_MAP } from '@/redux/models/models.mock';
import { MOCKED_OVERLAY_BIO_ENTITY_RENDER } from '@/redux/overlayBioEntity/overlayBioEntity.mock';
import { useOverlayFeatures } from './useOverlayFeatures';
/**
* mocks for useOverlayFeatures
* are taken from helpers functions that are used inside useOverlayFeatures
* point of the test is to test if all helper functions work correctly when combined together
*/
describe('useOverlayFeatures', () => {
const { Wrapper } = getReduxWrapperWithStore({
configuration: {
...CONFIGURATION_INITIAL_STORE_MOCKS,
},
overlayBioEntity: {
overlaysId: [11, 12],
data: {
// overlayId
11: {
// modelId
52: MOCKED_OVERLAY_BIO_ENTITY_RENDER,
53: MOCKED_OVERLAY_BIO_ENTITY_RENDER,
},
12: {
52: MOCKED_OVERLAY_BIO_ENTITY_RENDER,
53: MOCKED_OVERLAY_BIO_ENTITY_RENDER,
},
},
},
overlays: {
...OVERLAYS_PUBLIC_FETCHED_STATE_MOCK,
},
map: {
...mapStateWithCurrentlySelectedMainMapFixture,
},
models: {
...MODELS_DATA_MOCK_WITH_MAIN_MAP,
},
});
it('should return an array of features', () => {
const {
result: { current: features },
} = renderHook(() => useOverlayFeatures(), {
wrapper: Wrapper,
});
expect(features).toHaveLength(6);
expect(features[0].getGeometry()?.getCoordinates()).toEqual([
[
[-13149141, 18867005],
[-13149141, 18881970],
[-13143529, 18881970],
[-13143529, 18867005],
[-13149141, 18867005],
],
]);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
expect(features[0].getStyle().getFill().getColor()).toBe('#FFFFFFcc');
});
});
...@@ -40,3 +40,20 @@ export const initialMapStateFixture: MapState = { ...@@ -40,3 +40,20 @@ export const initialMapStateFixture: MapState = {
error: DEFAULT_ERROR, error: DEFAULT_ERROR,
openedMaps: openedMapsInitialValueFixture, openedMaps: openedMapsInitialValueFixture,
}; };
export const mapStateWithCurrentlySelectedMainMapFixture: MapState = {
data: {
...initialMapDataFixture,
modelId: 52,
size: {
width: 26779.25,
height: 13503,
tileSize: 256,
minZoom: 2,
maxZoom: 9,
},
},
loading: 'idle',
error: DEFAULT_ERROR,
openedMaps: openedMapsInitialValueFixture,
};
...@@ -6,3 +6,27 @@ export const MODELS_INITIAL_STATE_MOCK: ModelsState = { ...@@ -6,3 +6,27 @@ export const MODELS_INITIAL_STATE_MOCK: ModelsState = {
loading: 'idle', loading: 'idle',
error: DEFAULT_ERROR, error: DEFAULT_ERROR,
}; };
export const MODELS_DATA_MOCK_WITH_MAIN_MAP: ModelsState = {
data: [
{
idObject: 52,
width: 26779.25,
height: 13503,
defaultCenterX: null,
defaultCenterY: null,
description: '',
name: 'Core PD map',
defaultZoomLevel: null,
tileSize: 256,
references: [],
authors: [],
creationDate: null,
modificationDates: [],
minZoom: 2,
maxZoom: 9,
},
],
loading: 'idle',
error: DEFAULT_ERROR,
};
import { OverlayBioEntityRender } from '@/types/OLrendering';
import { OverlaysBioEntityState } from './overlayBioEntity.types'; import { OverlaysBioEntityState } from './overlayBioEntity.types';
export const OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK: OverlaysBioEntityState = { export const OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK: OverlaysBioEntityState = {
overlaysId: [], overlaysId: [],
data: [], data: [],
}; };
export const MOCKED_OVERLAY_BIO_ENTITY_RENDER: OverlayBioEntityRender[] = [
{
id: 1,
modelId: 52,
width: 30,
x1: 18412,
x2: 18492,
y1: 3128.653195488725,
y2: 3088.653195488725,
overlayId: 11,
height: 10,
value: 0,
color: null,
},
{
id: 2,
modelId: 52,
width: 30,
x1: 18412,
x2: 18492,
y1: 3128.653195488725,
y2: 3088.653195488725,
overlayId: 11,
height: 10,
value: -0.2137,
color: null,
},
{
id: 3,
modelId: 52,
width: 40,
x1: 18412,
x2: 18492,
y1: 3128.653195488725,
y2: 3088.653195488725,
overlayId: 11,
height: 10,
value: null,
color: { rgb: -65536, alpha: 0 },
},
];
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