|
| 1 | +import React from 'react'; |
| 2 | +import { shallow } from 'enzyme'; |
| 3 | +import { findByTestAtrr, checkProps } from './../../../Utils'; |
| 4 | +import ListItem from './index'; |
| 5 | + |
| 6 | +describe('ListItem Component', () => { |
| 7 | + |
| 8 | + describe('Checking PropTypes', () => { |
| 9 | + |
| 10 | + it('Should NOT throw a warning', () => { |
| 11 | + const expectedProps = { |
| 12 | + title: 'Example Title', |
| 13 | + desc: 'Some text' |
| 14 | + }; |
| 15 | + const propsError = checkProps(ListItem, expectedProps); |
| 16 | + expect(propsError).toBeUndefined(); |
| 17 | + }); |
| 18 | + |
| 19 | + }); |
| 20 | + |
| 21 | + describe('Component Renders', () => { |
| 22 | + |
| 23 | + let wrapper; |
| 24 | + beforeEach(() => { |
| 25 | + const props = { |
| 26 | + title: 'Example Title', |
| 27 | + desc: 'Some text' |
| 28 | + }; |
| 29 | + wrapper = shallow(<ListItem {...props} />); |
| 30 | + }); |
| 31 | + |
| 32 | + it('Should renders without error', () => { |
| 33 | + const component = findByTestAtrr(wrapper, 'listItemComponent'); |
| 34 | + expect(component.length).toBe(1); |
| 35 | + }); |
| 36 | + |
| 37 | + it('Should render a title', () => { |
| 38 | + const title = findByTestAtrr(wrapper, 'componentTitle'); |
| 39 | + expect(title.length).toBe(1); |
| 40 | + }); |
| 41 | + |
| 42 | + it('Should render a desc', () => { |
| 43 | + const desc = findByTestAtrr(wrapper, 'componentDesc'); |
| 44 | + expect(desc.length).toBe(1); |
| 45 | + }); |
| 46 | + |
| 47 | + |
| 48 | + }); |
| 49 | + |
| 50 | + |
| 51 | + describe('Should NOT render', () => { |
| 52 | + |
| 53 | + let wrapper; |
| 54 | + beforeEach(() => { |
| 55 | + const props = { |
| 56 | + desc: 'Some text' |
| 57 | + }; |
| 58 | + wrapper = shallow(<ListItem {...props} />); |
| 59 | + }); |
| 60 | + |
| 61 | + it('Component is not rendered', () => { |
| 62 | + const component = findByTestAtrr(wrapper, 'listItemComponent'); |
| 63 | + expect(component.length).toBe(0); |
| 64 | + }); |
| 65 | + |
| 66 | + }); |
| 67 | + |
| 68 | + |
| 69 | +}); |
| 70 | + |
0 commit comments