|
| 1 | +import React from 'react' |
| 2 | +import { shallow } from 'enzyme' |
| 3 | +import { List } from 'semantic-ui-react' |
| 4 | +import { Link } from 'react-router-dom'; |
| 5 | +import Footer, { LinksList } from '../../components/Footer' |
| 6 | + |
| 7 | +describe('Footer', () => { |
| 8 | + let wrapper |
| 9 | + |
| 10 | + describe('Footer component', () => { |
| 11 | + beforeEach(() => { |
| 12 | + wrapper = shallow(<Footer />) |
| 13 | + }) |
| 14 | + |
| 15 | + it('contains a div with class footer', () => { |
| 16 | + expect(wrapper.find('div.footer').length).toEqual(1) |
| 17 | + }) |
| 18 | + |
| 19 | + it('contains three LinkList components', () => { |
| 20 | + expect(wrapper.find(LinksList).length).toEqual(3) |
| 21 | + }) |
| 22 | + |
| 23 | + it('contains two content divs', () => { |
| 24 | + expect(wrapper.find('div.content').length).toEqual(2) |
| 25 | + }) |
| 26 | + |
| 27 | + it('contains a mailto link', () => { |
| 28 | + expect(wrapper.contains(<a href='mailto:info@agileventures.org'>info@agileventures.org</a>)).toEqual(true) |
| 29 | + }) |
| 30 | + }) |
| 31 | + |
| 32 | + describe('LinksList component', () => { |
| 33 | + let wrapper |
| 34 | + |
| 35 | + const props = [ |
| 36 | + { text: 'Text 1', href: '/href1' }, |
| 37 | + { text: 'Text 2', href: '/href2' }, |
| 38 | + { text: 'Text 3', href: '/href3' } |
| 39 | + ] |
| 40 | + beforeEach(() => { |
| 41 | + wrapper = shallow(<LinksList links={props} />) |
| 42 | + }) |
| 43 | + |
| 44 | + it('renders a List', () => { |
| 45 | + expect(wrapper.find(List).length).toEqual(1) |
| 46 | + }) |
| 47 | + |
| 48 | + it('renders the links', () => { |
| 49 | + expect(wrapper.find(Link).length).toEqual(props.length) |
| 50 | + }) |
| 51 | + |
| 52 | + it('renders the correct text and href for each link', () => { |
| 53 | + const links = wrapper.find(Link); |
| 54 | + |
| 55 | + for (let i = 0; i < links.length; i++) { |
| 56 | + expect(links.at(i).prop('to')).toEqual(props[i].href); |
| 57 | + expect(links.at(i).contains(props[i].text)).toEqual(true); |
| 58 | + } |
| 59 | + }); |
| 60 | + |
| 61 | + }) |
| 62 | +}) |
0 commit comments