Skip to content
Snippets Groups Projects

feat: add legend for active overlays

1 unresolved thread
1 file
+ 19
13
Compare changes
  • Side-by-side
  • Inline
import { BASE_API_URL, PROJECT_ID } from '@/constants';
import { overlaysFixture } from '@/models/fixtures/overlaysFixture';
import { OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK } from '@/redux/overlayBioEntity/overlayBioEntity.mock';
import {
OVERLAYS_PUBLIC_FETCHED_STATE_MOCK,
PUBLIC_OVERLAYS_MOCK,
} from '@/redux/overlays/overlays.mock';
import { StoreType } from '@/redux/store';
import {
InitialStoreState,
getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore';
import { render, screen } from '@testing-library/react';
import { activeOverlaysSelector } from '../../../../../redux/overlayBioEntity/overlayBioEntity.selector';
import { OverlaysLegends } from './OverlaysLegends.component';
jest.mock('../../../../../redux/overlayBioEntity/overlayBioEntity.selector', () => ({
activeOverlaysSelector: jest.fn(),
}));
const activeOverlaysSelectorMock = activeOverlaysSelector as unknown as jest.Mock;
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState);
@@ -33,8 +30,12 @@ const renderComponent = (initialStoreState: InitialStoreState = {}): { store: St
describe('OverlaysLegends - component', () => {
describe('when active overlays are empty', () => {
beforeEach(() => {
activeOverlaysSelectorMock.mockImplementation(() => []);
renderComponent();
renderComponent({
overlays: OVERLAYS_PUBLIC_FETCHED_STATE_MOCK,
overlayBioEntity: {
...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK,
},
});
});
it('should not render list of overlays legends', () => {
@@ -44,11 +45,16 @@ describe('OverlaysLegends - component', () => {
describe('when active overlays are present', () => {
beforeEach(() => {
activeOverlaysSelectorMock.mockImplementation(() => overlaysFixture);
renderComponent();
renderComponent({
overlays: OVERLAYS_PUBLIC_FETCHED_STATE_MOCK,
overlayBioEntity: {
...OVERLAY_BIO_ENTITY_INITIAL_STATE_MOCK,
overlaysId: PUBLIC_OVERLAYS_MOCK.map(o => o.idObject),
},
});
});
it.each(overlaysFixture)('should render overlay legend', overlay => {
it.each(PUBLIC_OVERLAYS_MOCK)('should render overlay legend', overlay => {
const image = screen.getByAltText(`${overlay.name} legend`);
expect(screen.getByText(overlay.name)).toBeInTheDocument();
Loading