Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit c6b7cf2

Browse files
author
george
committed
Merge branch 'develop'
2 parents d9a117d + 15867aa commit c6b7cf2

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

app/components/Footer/__tests__/Footer.spec.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,27 @@ jest.mock("react-feather/dist/icons/twitter", () => global.simpleMock("Twitter")
55
jest.mock("react-feather/dist/icons/github", () => global.simpleMock("Github"))
66

77
describe("<Footer />", () => {
8+
const baseProps = {
9+
handleHeaderFocusClick: jest.fn(),
10+
}
11+
12+
const mountComponent = () => {
13+
return mount(<Footer {...baseProps} />)
14+
}
15+
816
it("renders", () => {
9-
const wrapper = mount(<Footer handleHeaderFocusClick={jest.fn()} />)
17+
// Given
18+
const wrapper = mountComponent()
19+
// Then
1020
expect(wrapper).toMatchSnapshot()
1121
})
22+
23+
it("calls handleHeaderFocusClick prop when hidden button is clicked", () => {
24+
// Given
25+
const wrapper = mountComponent()
26+
// When
27+
wrapper.find(".is-visually-hidden-focusable").simulate("click")
28+
// Then
29+
expect(baseProps.handleHeaderFocusClick).toHaveBeenCalled()
30+
})
1231
})

app/components/GlobalNav/__tests__/GlobalNav.spec.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,32 @@ import React from "react"
22
import GlobalNav from "../GlobalNav"
33
import { BrowserRouter as Router } from "react-router-dom"
44

5-
function NavComponent() {
6-
return mount(
7-
<Router>
8-
<GlobalNav handleMainFocusClick={jest.fn()} />
9-
</Router>
10-
)
11-
}
12-
135
describe("<Nav />", () => {
6+
const baseProps = {
7+
handleMainFocusClick: jest.fn(),
8+
}
9+
10+
const mountComponent = () => {
11+
return mount(
12+
<Router>
13+
<GlobalNav {...baseProps} />
14+
</Router>
15+
)
16+
}
17+
1418
it("renders", () => {
15-
const wrapper = NavComponent()
19+
// Given
20+
const wrapper = mountComponent()
21+
// Then
1622
expect(wrapper).toMatchSnapshot()
1723
})
24+
25+
it("calls handleMainFocusClick prop when hidden button is clicked", () => {
26+
// Given
27+
const wrapper = mountComponent()
28+
// When
29+
wrapper.find(".is-visually-hidden-focusable").simulate("click")
30+
// Then
31+
expect(baseProps.handleMainFocusClick).toHaveBeenCalled()
32+
})
1833
})

0 commit comments

Comments
 (0)