Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover with tests ExpertPhotoDataCard component #672

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import ExpertPhotoDataCard from '../ExpertPhotoDataCard';
import { IExpert } from '../../../types';

const MOCK_DATA: IExpert = {
id: 6,
firstName: 'Таржеман',
lastName: 'Соколов',
email: 't.sokolov@mail.com',
qualification: 'Кандидат медичних наук',
phone: '+380633335533',
avatar: 'https://i.pravatar.cc/300?img=44',
bio:
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor ',
socialNetwork: 'https://www.youtube.com',
directions: [
{
id: 4,
name: 'therapy',
label: 'Терапія',
color: '#ffee58',
hasDoctors: true,
hasPosts: true,
},
],
mainInstitution: {
id: 4,
city: {
id: 119,
name: 'Дніпро',
},
name: 'Медікум',
},
lastAddedPost: {
id: 246,
title: 'Sit amet consectetur',
},
};

describe('ExpertPhotoDataCard test', () => {
it('should render component and match snapshot', () => {
const { asFragment } = render(
<MemoryRouter>
<ExpertPhotoDataCard expert={MOCK_DATA} />
</MemoryRouter>,
);
expect(asFragment()).toMatchSnapshot();
});
it("should render Expert's image", () => {
render(
<MemoryRouter>
<ExpertPhotoDataCard expert={MOCK_DATA} />
</MemoryRouter>,
);
expect(screen.getByAltText('doctor')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ExpertPhotoDataCard test should render component and match snapshot 1`] = `
<DocumentFragment>
<div
class="MuiPaper-root MuiCard-root ExpertPhotoDataCard-root-1 MuiPaper-elevation1 MuiPaper-rounded"
>
<a
href="/experts/6"
>
<div
class="MuiBox-root MuiBox-root-3 ExpertPhotoDataCard-photo-2"
>
<img
alt="doctor"
aria-hidden="true"
class="makeStyles-photo-4"
src="https://i.pravatar.cc/300?img=44"
/>
</div>
<div
class="MuiPaper-root MuiCard-root ExpertDataCard-root-5 MuiPaper-elevation1 MuiPaper-rounded"
>
<h4
class="MuiTypography-root ExpertDataCard-name-6 MuiTypography-h4"
>
Таржеман Соколов
</h4>
<h6
class="MuiTypography-root ExpertDataCard-qualification-7 MuiTypography-h6 MuiTypography-gutterBottom"
>
Кандидат медичних наук, Медікум, Дніпро
</h6>
</div>
</a>
</div>
</DocumentFragment>
`;