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

Tests for ExpertDataCard component #654

Merged
merged 1 commit into from
Nov 5, 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,58 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { ExpertDataCard } from '../ExpertDataCard';
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',
},
};

const renderExpertDataCard = () =>
render(<ExpertDataCard expert={MOCK_DATA} />);

describe('ExpertBlock test', () => {
beforeEach(() => renderExpertDataCard());
it('should render component and match snapshot', () => {
const { asFragment } = render(<ExpertDataCard expert={MOCK_DATA} />);
expect(asFragment()).toMatchSnapshot();
});
it("should render Expert's name", () => {
expect(screen.getByText('Таржеман Соколов')).toBeInTheDocument();
});
it("should render Expert's qualification, name of mainInstitution and city", () => {
expect(
screen.getByText('Кандидат медичних наук, Медікум, Дніпро'),
).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ExpertBlock test should render component and match snapshot 1`] = `
<DocumentFragment>
<div
class="MuiPaper-root MuiCard-root ExpertDataCard-root-1 MuiPaper-elevation1 MuiPaper-rounded"
>
<h4
class="MuiTypography-root ExpertDataCard-name-2 MuiTypography-h4"
>
Таржеман Соколов
</h4>
<h6
class="MuiTypography-root ExpertDataCard-qualification-3 MuiTypography-h6 MuiTypography-gutterBottom"
>
Кандидат медичних наук, Медікум, Дніпро
</h6>
</div>
</DocumentFragment>
`;