Skip to content
Snippets Groups Projects

Feat/bioentity from map

Merged Mateusz Bolewski requested to merge feat/bioentity-from-map into development
1 unresolved thread
16 files
+ 342
5
Compare changes
  • Side-by-side
  • Inline
Files
16
 
/* eslint-disable no-magic-numbers */
 
import {
 
InitialStoreState,
 
getReduxWrapperWithStore,
 
} from '@/utils/testing/getReduxWrapperWithStore';
 
import { render, screen } from '@testing-library/react';
 
import { DRAWER_INITIAL_STATE } from '@/redux/drawer/drawer.constants';
 
import { StoreType } from '@/redux/store';
 
import {
 
bioEntitiesContentFixture,
 
bioEntityContentFixture,
 
} from '@/models/fixtures/bioEntityContentsFixture';
 
import { FIRST_ARRAY_ELEMENT } from '@/constants/common';
 
import { BioEntityDrawer } from './BioEntityDrawer.component';
 
 
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
 
const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState);
 
 
return (
 
render(
 
<Wrapper>
 
<BioEntityDrawer />
 
</Wrapper>,
 
),
 
{
 
store,
 
}
 
);
 
};
 
 
describe('BioEntityDrawer - component', () => {
 
beforeEach(() => {
 
jest.resetAllMocks();
 
jest.clearAllMocks();
 
});
 
 
describe("when there's NO matching bioEntity", () => {
 
beforeEach(() =>
 
renderComponent({
 
bioEntity: {
 
data: [],
 
loading: 'succeeded',
 
error: { message: '', name: '' },
 
},
 
drawer: DRAWER_INITIAL_STATE,
 
}),
 
);
 
 
it('should not show drawer content', () => {
 
expect(screen.queryByText('Compartment:')).toBeNull();
 
expect(screen.queryByText('Full name:')).toBeNull();
 
expect(screen.queryByText('Annotations:')).toBeNull();
 
expect(screen.queryByText('Source:')).toBeNull();
 
});
 
});
 
describe('when there IS a matching bioEntity', () => {
 
const { bioEntity } = bioEntitiesContentFixture[FIRST_ARRAY_ELEMENT];
 
 
it('should show drawer header', () => {
 
renderComponent({
 
bioEntity: {
 
data: [
 
{
 
searchQueryElement: '',
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
data: bioEntitiesContentFixture,
 
},
 
],
 
loading: 'succeeded',
 
error: { message: '', name: '' },
 
},
 
drawer: {
 
...DRAWER_INITIAL_STATE,
 
bioEntityDrawerState: {
 
bioentityId: bioEntity.id,
 
},
 
},
 
});
 
 
expect(screen.getByText(bioEntity.stringType, { exact: false })).toBeInTheDocument();
 
expect(screen.getByText(bioEntity.name, { exact: false })).toBeInTheDocument();
 
});
 
 
it('should show drawer bioEntity full name', () => {
 
renderComponent({
 
bioEntity: {
 
data: [
 
{
 
searchQueryElement: '',
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
data: [
 
{
 
...bioEntityContentFixture,
 
bioEntity: {
 
...bioEntityContentFixture.bioEntity,
 
fullName: 'BioEntity Full Name',
 
},
 
},
 
],
 
},
 
],
 
loading: 'succeeded',
 
error: { message: '', name: '' },
 
},
 
drawer: {
 
...DRAWER_INITIAL_STATE,
 
bioEntityDrawerState: {
 
bioentityId: bioEntityContentFixture.bioEntity.id,
 
},
 
},
 
});
 
 
expect(screen.getByText('Full name:', { exact: false })).toBeInTheDocument();
 
expect(screen.getByText('BioEntity Full Name', { exact: false })).toBeInTheDocument();
 
});
 
 
it("should not show drawer bioEntity full name if it doesn't exists", () => {
 
renderComponent({
 
bioEntity: {
 
data: [
 
{
 
searchQueryElement: '',
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
data: [
 
{
 
...bioEntityContentFixture,
 
bioEntity: {
 
...bioEntityContentFixture.bioEntity,
 
fullName: null,
 
},
 
},
 
],
 
},
 
],
 
loading: 'succeeded',
 
error: { message: '', name: '' },
 
},
 
drawer: {
 
...DRAWER_INITIAL_STATE,
 
bioEntityDrawerState: {
 
bioentityId: bioEntityContentFixture.bioEntity.id,
 
},
 
},
 
});
 
 
expect(screen.queryByText('Full name:')).toBeNull();
 
});
 
 
it('should show list of annotations ', () => {
 
renderComponent({
 
bioEntity: {
 
data: [
 
{
 
searchQueryElement: '',
 
loading: 'succeeded',
 
error: { name: '', message: '' },
 
data: bioEntitiesContentFixture,
 
},
 
],
 
loading: 'succeeded',
 
error: { message: '', name: '' },
 
},
 
drawer: {
 
...DRAWER_INITIAL_STATE,
 
bioEntityDrawerState: {
 
bioentityId: bioEntity.id,
 
},
 
},
 
});
 
 
expect(screen.getByText('Annotations:')).toBeInTheDocument();
 
expect(screen.getByText(bioEntity.references[0].type, { exact: false })).toBeInTheDocument();
 
expect(
 
screen.getByText(bioEntity.references[0].resource, { exact: false }),
 
).toBeInTheDocument();
 
});
 
});
 
});
Loading