Skip to content

Commit e101b38

Browse files
jmpainterjoaopapereira
authored andcommitted
added test for footer
1 parent d7ec5da commit e101b38

File tree

2 files changed

+68
-6
lines changed

2 files changed

+68
-6
lines changed

src/components/Footer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ const LINKS = {
2424
]
2525
}
2626

27-
const LinksList = ({ links }) => (
27+
export const LinksList = ({ links }) => (
2828
<List>
2929
{links.map(link => (
3030
<List.Item key={link.href}>
31-
{ link.href.startsWith('/') ? (
31+
{link.href.startsWith('/') ? (
3232
<Link to={link.href}>
3333
{link.text}
3434
</Link>
3535
) : (
36-
<a href={link.href} target='_blank' rel='noreferrer'>
37-
{link.text}
38-
</a>
39-
)}
36+
<a href={link.href} target='_blank' rel='noreferrer'>
37+
{link.text}
38+
</a>
39+
)}
4040
</List.Item>
4141
))}
4242
</List>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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

Comments
 (0)