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

test(publications): added missing tests

parent eda2e1fb
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...,!127Test/publications missing tests
Pipeline #85535 passed
import { mockNetworkResponse } from '@/utils/mockNetworkResponse';
mockNetworkResponse();
/**
* Since data to table is passed down from Publications Modal component
* this test will be covered in the integration test for the Publications Table component
* and interactions beetween filtering, sorting, searching and pagination
*/
describe('Publications Modal - component', () => { describe('Publications Modal - component', () => {
it('should render number of publications', () => {}); it('should render number of publications', () => {});
it('should render download csv button', () => {}); it('should render download csv button', () => {});
......
import {
InitialStoreState,
getReduxWrapperWithStore,
} from '@/utils/testing/getReduxWrapperWithStore';
import { StoreType } from '@/redux/store';
import { render, screen } from '@testing-library/react';
import { PUBLICATIONS_DEFAULT_SEARCH_FIRST_10_STATE_MOCK } from '@/redux/publications/publications.mock';
import { PublicationsModalLayout } from './PublicationsModalLayout.component';
const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => {
const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState);
return (
render(
<Wrapper>
<PublicationsModalLayout>
<div>children</div>
</PublicationsModalLayout>
</Wrapper>,
),
{
store,
}
);
};
describe('Publications Modal Layout - component', () => {
it('should render number of publications', () => {
renderComponent({ publications: PUBLICATIONS_DEFAULT_SEARCH_FIRST_10_STATE_MOCK });
expect(screen.getByText('Publications (1586 results)')).toBeInTheDocument();
});
it.skip('should render download csv button', () => {});
it.skip('should trigger download on csv button click', () => {});
it('should render search input', () => {
renderComponent({ publications: PUBLICATIONS_DEFAULT_SEARCH_FIRST_10_STATE_MOCK });
expect(screen.getByTestId('search-input')).toBeInTheDocument();
});
it('should render children', () => {
renderComponent({ publications: PUBLICATIONS_DEFAULT_SEARCH_FIRST_10_STATE_MOCK });
expect(screen.getByText('children')).toBeInTheDocument();
});
});
// remember to mock api call
describe('PublicationsSearch', () => {
it('should render the input field', () => {});
it('should update the value when the input field changes', () => {});
it('should dispatch getPublications action when the input field changes', () => {});
it('should disable the input and button when isLoading is true', () => {});
});
export const PUBLICATIONS_DEFAULT_SEARCH_FIRST_10_MOCK = {
data: [
{
elements: [
{
id: 19519,
modelId: 52,
type: 'REACTION',
},
],
publication: {
article: {
title: 'The glutamate receptor ion channels.',
authors: ['Dingledine R', ' Borges K', ' Bowie D', ' Traynelis SF.'],
journal: 'Pharmacological reviews',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10049997',
pubmedId: '10049997',
citationCount: 2458,
},
},
},
{
elements: [
{
id: 16167,
modelId: 61,
type: 'REACTION',
},
],
publication: {
article: {
title: 'Regulation of JNK signaling by GSTp.',
authors: [
'Adler V',
' Yin Z',
' Fuchs SY',
' Benezra M',
' Rosario L',
' Tew KD',
' Pincus MR',
' Sardana M',
' Henderson CJ',
' Wolf CR',
' Davis RJ',
' Ronai Z.',
],
journal: 'The EMBO journal',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10064598',
pubmedId: '10064598',
citationCount: 656,
},
},
},
{
elements: [
{
id: 17823,
modelId: 52,
type: 'REACTION',
},
{
id: 19461,
modelId: 52,
type: 'REACTION',
},
],
publication: {
article: {
title:
'Generic signals and specific outcomes: signaling through Ca2+, calcineurin, and NF-AT.',
authors: ['Crabtree GR.'],
journal: 'Cell',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10089876',
pubmedId: '10089876',
citationCount: 454,
},
},
},
{
elements: [
{
id: 18189,
modelId: 52,
type: 'REACTION',
},
{
id: 18729,
modelId: 52,
type: 'REACTION',
},
],
publication: {
article: {
title: 'G protein regulation of adenylate cyclase.',
authors: ['Simonds WF.'],
journal: 'Trends in pharmacological sciences',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10101967',
pubmedId: '10101967',
citationCount: 139,
},
},
},
{
elements: [
{
id: 16077,
modelId: 58,
type: 'REACTION',
},
{
id: 16135,
modelId: 58,
type: 'REACTION',
},
],
publication: {
article: {
title:
'Akt promotes cell survival by phosphorylating and inhibiting a Forkhead transcription factor.',
authors: [
'Brunet A',
' Bonni A',
' Zigmond MJ',
' Lin MZ',
' Juo P',
' Hu LS',
' Anderson MJ',
' Arden KC',
' Blenis J',
' Greenberg ME.',
],
journal: 'Cell',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10102273',
pubmedId: '10102273',
citationCount: 4019,
},
},
},
{
elements: [
{
id: 15955,
modelId: 55,
type: 'REACTION',
},
],
publication: {
article: {
title: 'Ca2+-induced apoptosis through calcineurin dephosphorylation of BAD.',
authors: [
'Wang HG',
' Pathan N',
' Ethell IM',
' Krajewski S',
' Yamaguchi Y',
' Shibasaki F',
' McKeon F',
' Bobo T',
' Franke TF',
' Reed JC.',
],
journal: 'Science (New York, N.Y.)',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10195903',
pubmedId: '10195903',
citationCount: 708,
},
},
},
{
elements: [
{
id: 15937,
modelId: 55,
type: 'REACTION',
},
{
id: 15955,
modelId: 55,
type: 'REACTION',
},
],
publication: {
article: {
title:
'The proapoptotic activity of the Bcl-2 family member Bim is regulated by interaction with the dynein motor complex.',
authors: ['Puthalakath H', ' Huang DC', " O'Reilly LA", ' King SM', ' Strasser A.'],
journal: 'Molecular cell',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10198631',
pubmedId: '10198631',
citationCount: 662,
},
},
},
{
elements: [
{
id: 15948,
modelId: 55,
type: 'REACTION',
},
],
publication: {
article: {
title:
'An APAF-1.cytochrome c multimeric complex is a functional apoptosome that activates procaspase-9.',
authors: ['Zou H', ' Li Y', ' Liu X', ' Wang X.'],
journal: 'The Journal of biological chemistry',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10206961',
pubmedId: '10206961',
citationCount: 1162,
},
},
},
{
elements: [
{
id: 16286,
modelId: 62,
type: 'REACTION',
},
],
publication: {
article: {
title:
'Biochemical characterization and crystal structure determination of human heart short chain L-3-hydroxyacyl-CoA dehydrogenase provide insights into catalytic mechanism.',
authors: [
'Barycki JJ',
" O'Brien LK",
' Bratt JM',
' Zhang R',
' Sanishvili R',
' Strauss AW',
' Banaszak LJ.',
],
journal: 'Biochemistry',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10231530',
pubmedId: '10231530',
citationCount: 56,
},
},
},
{
elements: [
{
id: 17780,
modelId: 52,
type: 'REACTION',
},
{
id: 17937,
modelId: 52,
type: 'REACTION',
},
],
publication: {
article: {
title: 'The Ca-calmodulin-dependent protein kinase cascade.',
authors: ['Soderling TR.'],
journal: 'Trends in biochemical sciences',
year: 1999,
link: 'https://www.ncbi.nlm.nih.gov/pubmed/10366852',
pubmedId: '10366852',
citationCount: 322,
},
},
},
],
totalSize: 159,
filteredSize: 1586,
length: 10,
page: 0,
};
import { PUBLICATIONS_DEFAULT_SEARCH_FIRST_10_MOCK } from '@/models/mocks/publicationsResponseMock';
import { PublicationsState } from './publications.types'; import { PublicationsState } from './publications.types';
export const PUBLICATIONS_INITIAL_STATE_MOCK: PublicationsState = { export const PUBLICATIONS_INITIAL_STATE_MOCK: PublicationsState = {
...@@ -9,3 +10,13 @@ export const PUBLICATIONS_INITIAL_STATE_MOCK: PublicationsState = { ...@@ -9,3 +10,13 @@ export const PUBLICATIONS_INITIAL_STATE_MOCK: PublicationsState = {
searchValue: '', searchValue: '',
selectedModelId: undefined, selectedModelId: undefined,
}; };
export const PUBLICATIONS_DEFAULT_SEARCH_FIRST_10_STATE_MOCK: PublicationsState = {
data: PUBLICATIONS_DEFAULT_SEARCH_FIRST_10_MOCK,
loading: 'idle',
error: { name: '', message: '' },
sortColumn: '',
sortOrder: 'asc',
searchValue: '',
selectedModelId: undefined,
};
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