Skip to content
Snippets Groups Projects

refactor(mirnas): removed mirnas from source code

Merged Tadeusz Miesiąc requested to merge MIN-173/remove-mirna-from-source into development
37 files
+ 18
535
Compare changes
  • Side-by-side
  • Inline
Files
37
import { act, render, screen } from '@testing-library/react';
import { StoreType } from '@/redux/store';
import {
InitialStoreState,
getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore';
import { Accordion } from '@/shared/Accordion';
import {
drawerSearchStepOneFixture,
drawerSearchMirnaStepTwoFixture,
} from '@/redux/drawer/drawerFixture';
import { mirnasFixture } from '@/models/fixtures/mirnasFixture';
import { MirnaAccordion } from './MirnaAccordion.component';
const SECOND_STEP = 2;
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState);
return (
render(
<Wrapper>
<Accordion>
<MirnaAccordion />
</Accordion>
</Wrapper>,
),
{
store,
}
);
};
describe('MirnaAccordion - component', () => {
it('should display mirna number after succesfull mirna search', () => {
renderComponent({
mirnas: {
data: [
{
searchQueryElement: '',
loading: 'succeeded',
error: { name: '', message: '' },
data: mirnasFixture,
},
],
loading: 'succeeded',
error: { name: '', message: '' },
},
});
expect(screen.getByText('MiRNA (4)')).toBeInTheDocument();
});
it('should display loading indicator while waiting for mirna search response', () => {
renderComponent({
mirnas: { data: [], loading: 'pending', error: { name: '', message: '' } },
});
expect(screen.getByText('MiRNA (Loading...)')).toBeInTheDocument();
});
it('should navigate user to mirnas results list after clicking button', async () => {
const { store } = renderComponent({
mirnas: {
data: [
{
searchQueryElement: '',
loading: 'succeeded',
error: { name: '', message: '' },
data: mirnasFixture,
},
],
loading: 'succeeded',
error: { name: '', message: '' },
},
drawer: drawerSearchMirnaStepTwoFixture,
});
const navigationButton = screen.getByTestId('accordion-item-button');
await act(() => {
navigationButton.click();
});
const {
drawer: {
searchDrawerState: { stepType, selectedValue, currentStep },
},
} = store.getState();
expect(stepType).toBe('mirna');
expect(selectedValue).toBe(undefined);
expect(currentStep).toBe(SECOND_STEP);
});
it('should disable navigation button when there is no mirnas', async () => {
renderComponent({
mirnas: { data: [], loading: 'succeeded', error: { name: '', message: '' } },
drawer: drawerSearchStepOneFixture,
});
const navigationButton = screen.getByTestId('accordion-item-button');
expect(navigationButton).toBeDisabled();
});
it('should disable navigation button when waiting for api response', async () => {
renderComponent({
mirnas: { data: [], loading: 'pending', error: { name: '', message: '' } },
drawer: drawerSearchStepOneFixture,
});
const navigationButton = screen.getByTestId('accordion-item-button');
expect(navigationButton).toBeDisabled();
});
});
Loading