|
| 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