Skip to content
Snippets Groups Projects

feat: Add reaction drawer (MIN-140)

Merged Adrian Orłów requested to merge MIN-140-display-reaction-details-on-drawer into development
All threads resolved!
Files
35
import { StoreType } from '@/redux/store';
import { ReferenceFiltered } from '@/types/reference';
import {
InitialStoreState,
getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore';
import { render, screen } from '@testing-library/react';
import { Props, ReferenceGroup } from './ReferenceGroup.component';
const renderComponent = (
props: Props,
initialStoreState: InitialStoreState = {},
): { store: StoreType } => {
const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState);
return (
render(
<Wrapper>
<ReferenceGroup {...props} />
</Wrapper>,
),
{
store,
}
);
};
describe('ReactionDrawer - component', () => {
beforeEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
});
const singleReference = {
link: 'https://www.ncbi.nlm.nih.gov/pubmed/24448649',
article: {
title:
'The nutrient-responsive transcription factor TFE3 promotes autophagy, lysosomal biogenesis, and clearance of cellular debris.',
authors: [
'Martina JA',
' Diab HI',
' Lishu L',
' Jeong-A L',
' Patange S',
' Raben N',
' Puertollano R.',
],
journal: 'Science signaling',
year: 2014,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/24448649',
pubmedId: '24448649',
citationCount: 321,
},
type: 'PUBMED',
resource: '24448649',
id: 154973,
annotatorClassName: '',
};
const cases: [string, ReferenceFiltered[]][] = [
['', [singleReference]],
[
'source1',
[
{
...singleReference,
annotatorClassName: 'source1',
id: 1,
},
{
...singleReference,
annotatorClassName: 'source1',
id: 2,
},
],
],
[
'source2',
[
{
...singleReference,
annotatorClassName: 'source2',
id: 3,
},
],
],
];
it.each(cases)('should show reference group with source=%s', (source, references) => {
const referencesTextHref: [string, string][] = references.map(ref => [
`${ref.type} (${ref.id})`,
ref.link as string,
]);
renderComponent({
group: {
source,
references,
},
});
referencesTextHref.forEach(([refText, href]) => {
const linkReferenceSpan = screen.getByText(refText, { exact: false });
const linkReferenceAnchor = linkReferenceSpan.closest('a');
expect(linkReferenceSpan).toBeInTheDocument();
expect(linkReferenceAnchor).toBeInTheDocument();
expect(linkReferenceAnchor?.href).toBe(`${href}`);
});
});
});
Loading