Skip to content
Snippets Groups Projects

feat(project info): initialised project info drawer

Merged Tadeusz Miesiąc requested to merge feature/project-info-tab into development
1 unresolved thread
20 files
+ 349
15
Compare changes
  • Side-by-side
  • Inline
Files
20
 
import { act } from 'react-dom/test-utils';
 
import { render, screen } from '@testing-library/react';
 
import {
 
InitialStoreState,
 
getReduxWrapperWithStore,
 
} from '@/utils/testing/getReduxWrapperWithStore';
 
import { projectFixture } from '@/models/fixtures/projectFixture';
 
import { StoreType } from '@/redux/store';
 
import { MODEL_WITH_DESCRIPTION } from '@/models/mocks/modelsMock';
 
import { ProjectInfoDrawer } from './ProjectInfoDrawer.component';
 
 
const MOCKED_STORE: InitialStoreState = {
 
project: {
 
data: { ...projectFixture },
 
loading: 'idle',
 
error: new Error(),
 
},
 
models: {
 
data: [MODEL_WITH_DESCRIPTION],
 
loading: 'idle',
 
error: new Error(),
 
},
 
};
 
 
const renderComponent = (initialStore?: InitialStoreState): { store: StoreType } => {
 
const { Wrapper, store } = getReduxWrapperWithStore(initialStore);
 
return (
 
render(
 
<Wrapper>
 
<ProjectInfoDrawer />
 
</Wrapper>,
 
),
 
{
 
store,
 
}
 
);
 
};
 
 
describe('ProjectInfoDrawer', () => {
Please register or sign in to reply
 
it('should render the project name', () => {
 
renderComponent(MOCKED_STORE);
 
 
expect(screen.getByText(projectFixture.name)).toBeInTheDocument();
 
});
 
 
it('should render the version', () => {
 
renderComponent(MOCKED_STORE);
 
 
expect(screen.getByText(projectFixture.version)).toBeInTheDocument();
 
});
 
 
it.skip('should render number of publications', () => {});
 
it.skip('should open publications modal when publications link is clicked', () => {});
 
 
it('should render the manual link', () => {
 
renderComponent(MOCKED_STORE);
 
 
const manualLink = screen.getByText(/Manual/i);
 
expect(manualLink).toBeInTheDocument();
 
expect(manualLink).toHaveAttribute('href', 'https://minerva.pages.uni.lu/doc/');
 
});
 
 
it('should render the disease link with name and href', async () => {
 
await act(() => {
 
renderComponent(MOCKED_STORE);
 
});
 
 
const diseaseLink = screen.getByText(/Disease:/i);
 
expect(diseaseLink).toBeInTheDocument();
 
 
const linkelement = screen.getByRole('link', { name: projectFixture.diseaseName });
 
expect(linkelement).toBeInTheDocument();
 
expect(linkelement).toHaveAttribute('href', projectFixture.disease.link);
 
});
 
 
it('should fetch diesease name when diseaseId is provided', async () => {
 
await act(() => {
 
renderComponent(MOCKED_STORE);
 
});
 
 
const organismLink = screen.getByText(/Organism:/i);
 
expect(organismLink).toBeInTheDocument();
 
 
const linkelement = screen.getByRole('link', { name: projectFixture.organismName });
 
expect(linkelement).toBeInTheDocument();
 
expect(linkelement).toHaveAttribute('href', projectFixture.organism.link);
 
});
 
 
it('should render the source file download button', () => {
 
renderComponent(MOCKED_STORE);
 
 
const downloadButton = screen.getByRole('link', { name: /Download source file/i });
 
expect(downloadButton).toBeInTheDocument();
 
expect(downloadButton).toHaveAttribute(
 
'href',
 
'localhost/projects/pdmap_appu_test:downloadSource',
 
);
 
expect(downloadButton).toHaveAttribute('download', 'sourceFile.txt');
 
});
 
 
it('should render the description when it exists', () => {
 
renderComponent(MOCKED_STORE);
 
 
const desc = screen.getByTestId('project-description');
 
 
expect(desc.innerHTML).toContain(
 
'For information on content, functionalities and referencing the Parkinson\'s disease map, click <a href="http://pdmap.uni.lu" target="_blank">here</a>',
 
);
 
});
 
 
it.skip('should not render the description when it does not exist', () => {
 
renderComponent();
 
 
const descriptionElement = screen.queryByText('This is the project description.');
 
expect(descriptionElement).not.toBeInTheDocument();
 
});
 
});
Loading