Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit fd7a273

Browse files
author
M-ZubairAhmed
committed
added a sample test for common-banner component
1 parent e1242a4 commit fd7a273

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Testing CommonBanner of \`components/common-banner\` Check the snapshot 1`] = `
4+
<div
5+
className="jsx-1924801089"
6+
>
7+
<div
8+
className="jsx-1924801089 root"
9+
>
10+
<h1
11+
className="jsx-1924801089 headline"
12+
/>
13+
<h2
14+
className="jsx-1924801089"
15+
/>
16+
</div>
17+
<JSXStyle
18+
css=".root.jsx-1924801089{background-color:#f4f7fb;min-height:150px;text-align:center;padding-top:30px;padding-bottom:30px;}.headline.jsx-1924801089{font-size:4em;color:#df1cb5;font-weight:900;}h2.jsx-1924801089{max-width:1024px;margin-left:auto;margin-right:auto;-webkit-letter-spacing:2px;-moz-letter-spacing:2px;-ms-letter-spacing:2px;letter-spacing:2px;line-height:2;}@media (max-width:720px){h2.jsx-1924801089{font-size:14px;padding:0 10px;}}"
19+
styleId="1924801089"
20+
/>
21+
</div>
22+
`;

__tests__/common-banner.test.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
4+
import CommonBanner from '../components/common-banner';
5+
6+
describe('Testing CommonBanner of `components/common-banner`', () => {
7+
const shallowWrapper = shallow(<CommonBanner />);
8+
9+
it('Check the snapshot', () => {
10+
expect(shallowWrapper).toMatchSnapshot();
11+
});
12+
13+
it('should have title tag rendered', () => {
14+
expect(shallowWrapper.find('h1').length).toBe(1);
15+
});
16+
17+
it('should have subtitle tag rendered', () => {
18+
expect(shallowWrapper.find('h2').length).toBe(1);
19+
});
20+
21+
describe('should render the props', () => {
22+
const pageTitle = 'title of the page';
23+
const pageSubTitle = 'Subtitle of the page';
24+
const rootWrapper = shallow(
25+
<CommonBanner pageTitle={pageTitle} pageSubTitle={pageSubTitle} />,
26+
);
27+
28+
it('should display title', () => {
29+
const headerElement = rootWrapper.find('.headline');
30+
expect(headerElement.props().children).toEqual(pageTitle);
31+
});
32+
33+
it('should display subtitle', () => {
34+
const subHeaderElement = rootWrapper.find('h2');
35+
expect(subHeaderElement.props().children).toEqual(pageSubTitle);
36+
});
37+
});
38+
});

0 commit comments

Comments
 (0)