This repository was archived by the owner on Oct 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-86
lines changed
Expand file tree Collapse file tree 3 files changed +19
-86
lines changed Original file line number Diff line number Diff line change @@ -22,27 +22,38 @@ const mountComponent = newProps => {
2222describe ( "<PageHeader />" , ( ) => {
2323 describe ( "#render" , ( ) => {
2424 it ( "renders" , ( ) => {
25+ // Given
2526 const wrapper = mountComponent ( )
27+ // Then
2628 expect ( wrapper ) . toMatchSnapshot ( )
2729 } )
2830 } )
2931
3032 describe ( "#state" , ( ) => {
3133 it ( "does not focus header if lastLocation prop is not passed" , ( ) => {
34+ // Given
3235 const wrapper = mountComponent ( )
36+ // When
3337 const headerFocused = wrapper . find ( "h1" ) . is ( ":focus" )
38+ // Then
3439 expect ( headerFocused ) . toBe ( false )
3540 } )
3641
3742 it ( "focuses header if lastLocation prop is passed" , ( ) => {
43+ // Given
3844 const wrapper = mountComponent ( { lastLocation : { location : "/new-location" } } )
45+ // When
3946 const headerFocused = wrapper . find ( "h1" ) . is ( ":focus" )
47+ // Then
4048 expect ( headerFocused ) . toBe ( true )
4149 } )
4250
4351 it ( "resets h1 tabIndex to null when blurred" , ( ) => {
52+ // Given
4453 const wrapper = mountComponent ( { lastLocation : { location : "/new-location" } } )
54+ // When
4555 wrapper . find ( "h1" ) . simulate ( "blur" )
56+ // Then
4657 expect ( wrapper . find ( "h1" ) . props ( ) . tabIndex ) . toEqual ( UNFOCUSABLE_TABINDEX )
4758 } )
4859 } )
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import React from "react"
22import { BrowserRouter as Router } from "react-router-dom"
33import Main from "../Main"
44
5+ jest . mock ( "react-feather/dist/icons/twitter" , ( ) => global . simpleMock ( "Twitter" ) )
6+ jest . mock ( "react-feather/dist/icons/github" , ( ) => global . simpleMock ( "Github" ) )
57jest . mock ( "app/pages/Home" , ( ) => global . simpleMock ( "Home" ) )
68jest . mock ( "app/pages/Docs" , ( ) => global . simpleMock ( "Docs" ) )
79jest . mock ( "app/components/PageNotFound" , ( ) => global . simpleMock ( "PageNotFound" ) )
Original file line number Diff line number Diff line change @@ -87,29 +87,9 @@ exports[`<Main /> #render renders 1`] = `
8787 role = " listitem"
8888 >
8989 <Twitter
90- color = " currentColor"
9190 focusable = " false"
9291 role = " presentation"
93- size = " 24"
94- >
95- <svg
96- fill = " none"
97- focusable = " false"
98- height = " 24"
99- role = " presentation"
100- stroke = " currentColor"
101- strokeLinecap = " round"
102- strokeLinejoin = " round"
103- strokeWidth = " 2"
104- viewBox = " 0 0 24 24"
105- width = " 24"
106- xmlns = " http://www.w3.org/2000/svg"
107- >
108- <path
109- d = " M23 3a10.9 10.9 0 0 1-3.14 1.53 4.48 4.48 0 0 0-7.86 3v1A10.66 10.66 0 0 1 3 4s-4 9 5 13a11.64 11.64 0 0 1-7 2c9 5 20 0 20-11.5a4.5 4.5 0 0 0-.08-.83A7.72 7.72 0 0 0 23 3z"
110- />
111- </svg >
112- </Twitter >
92+ />
11393 <span
11494 className = " is-visually-hidden"
11595 >
@@ -125,30 +105,10 @@ exports[`<Main /> #render renders 1`] = `
125105 href = " https://www.github.com/geotrev/undernet"
126106 role = " listitem"
127107 >
128- <GitHub
129- color = " currentColor"
108+ <Github
130109 focusable = " false"
131110 role = " presentation"
132- size = " 24"
133- >
134- <svg
135- fill = " none"
136- focusable = " false"
137- height = " 24"
138- role = " presentation"
139- stroke = " currentColor"
140- strokeLinecap = " round"
141- strokeLinejoin = " round"
142- strokeWidth = " 2"
143- viewBox = " 0 0 24 24"
144- width = " 24"
145- xmlns = " http://www.w3.org/2000/svg"
146- >
147- <path
148- d = " M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"
149- />
150- </svg >
151- </GitHub >
111+ />
152112 <span
153113 className = " is-visually-hidden"
154114 >
@@ -297,29 +257,9 @@ exports[`<Main /> #render renders 1`] = `
297257 role = " listitem"
298258 >
299259 <Twitter
300- color = " currentColor"
301260 focusable = " false"
302261 role = " presentation"
303- size = " 24"
304- >
305- <svg
306- fill = " none"
307- focusable = " false"
308- height = " 24"
309- role = " presentation"
310- stroke = " currentColor"
311- strokeLinecap = " round"
312- strokeLinejoin = " round"
313- strokeWidth = " 2"
314- viewBox = " 0 0 24 24"
315- width = " 24"
316- xmlns = " http://www.w3.org/2000/svg"
317- >
318- <path
319- d = " M23 3a10.9 10.9 0 0 1-3.14 1.53 4.48 4.48 0 0 0-7.86 3v1A10.66 10.66 0 0 1 3 4s-4 9 5 13a11.64 11.64 0 0 1-7 2c9 5 20 0 20-11.5a4.5 4.5 0 0 0-.08-.83A7.72 7.72 0 0 0 23 3z"
320- />
321- </svg >
322- </Twitter >
262+ />
323263 <span
324264 className = " is-visually-hidden"
325265 >
@@ -335,30 +275,10 @@ exports[`<Main /> #render renders 1`] = `
335275 href = " https://www.github.com/geotrev/undernet"
336276 role = " listitem"
337277 >
338- <GitHub
339- color = " currentColor"
278+ <Github
340279 focusable = " false"
341280 role = " presentation"
342- size = " 24"
343- >
344- <svg
345- fill = " none"
346- focusable = " false"
347- height = " 24"
348- role = " presentation"
349- stroke = " currentColor"
350- strokeLinecap = " round"
351- strokeLinejoin = " round"
352- strokeWidth = " 2"
353- viewBox = " 0 0 24 24"
354- width = " 24"
355- xmlns = " http://www.w3.org/2000/svg"
356- >
357- <path
358- d = " M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"
359- />
360- </svg >
361- </GitHub >
281+ />
362282 <span
363283 className = " is-visually-hidden"
364284 >
You can’t perform that action at this time.
0 commit comments