This repository was archived by the owner on Oct 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +44
-10
lines changed
Expand file tree Collapse file tree 2 files changed +44
-10
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,27 @@ jest.mock("react-feather/dist/icons/twitter", () => global.simpleMock("Twitter")
55jest . mock ( "react-feather/dist/icons/github" , ( ) => global . simpleMock ( "Github" ) )
66
77describe ( "<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} )
Original file line number Diff line number Diff line change @@ -2,17 +2,32 @@ import React from "react"
22import GlobalNav from "../GlobalNav"
33import { 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-
135describe ( "<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} )
You can’t perform that action at this time.
0 commit comments