Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Fix focus (#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels authored Feb 7, 2020
1 parent 376df6c commit ba62046
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 31 deletions.
29 changes: 15 additions & 14 deletions f2/src/__tests__/BusinessPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<BusinessPage />', () => {
afterEach(cleanup)
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
render(
<MemoryRouter initialEntries={['/']}>
<ThemeProvider theme={canada}>
<StateProvider initialState={initialState} reducer={reducer}>
<I18nProvider i18n={i18n}>
<BusinessPage />
</I18nProvider>
</StateProvider>
</ThemeProvider>
</MemoryRouter>,
)
})
it('renders', () => {
render(
<MemoryRouter initialEntries={['/']}>
<ThemeProvider theme={canada}>
<StateProvider initialState={initialState} reducer={reducer}>
<I18nProvider i18n={i18n}>
<BusinessPage />
</I18nProvider>
</StateProvider>
</ThemeProvider>
</MemoryRouter>,
)
})
})
1 change: 1 addition & 0 deletions f2/src/__tests__/CancelPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<CancelPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
1 change: 1 addition & 0 deletions f2/src/__tests__/ConfirmCancelPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<ConfirmCancelPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
1 change: 1 addition & 0 deletions f2/src/__tests__/ConfirmationSummary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<ConfirmationSummary />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
1 change: 1 addition & 0 deletions f2/src/__tests__/ContactInfoPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<ContactInfoPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
3 changes: 2 additions & 1 deletion f2/src/__tests__/DevicesPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<DevicesPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand All @@ -28,4 +29,4 @@ describe('<DevicesPage />', () => {
</MemoryRouter>,
)
})
})
})
1 change: 1 addition & 0 deletions f2/src/__tests__/FeedbackPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<FeedbackPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
29 changes: 15 additions & 14 deletions f2/src/__tests__/InformationPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<InformationPage />', () => {
afterEach(cleanup)
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
render(
<MemoryRouter initialEntries={['/']}>
<ThemeProvider theme={canada}>
<StateProvider initialState={initialState} reducer={reducer}>
<I18nProvider i18n={i18n}>
<InformationPage />
</I18nProvider>
</StateProvider>
</ThemeProvider>
</MemoryRouter>,
)
})
it('renders', () => {
render(
<MemoryRouter initialEntries={['/']}>
<ThemeProvider theme={canada}>
<StateProvider initialState={initialState} reducer={reducer}>
<I18nProvider i18n={i18n}>
<InformationPage />
</I18nProvider>
</StateProvider>
</ThemeProvider>
</MemoryRouter>,
)
})
})
1 change: 1 addition & 0 deletions f2/src/__tests__/LandingPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<LandingPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
1 change: 1 addition & 0 deletions f2/src/__tests__/LocationPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<LocationPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
3 changes: 2 additions & 1 deletion f2/src/__tests__/PrivacyConsentPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<PrivacyConsentPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand All @@ -28,4 +29,4 @@ describe('<PrivacyConsentPage />', () => {
</MemoryRouter>,
)
})
})
})
1 change: 1 addition & 0 deletions f2/src/__tests__/WhatHappenedPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<WhatHappenedPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
1 change: 1 addition & 0 deletions f2/src/__tests__/WhatWasAffectedPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<ImpactStatementPage />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
1 change: 1 addition & 0 deletions f2/src/components/footer/__tests__/Footer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<Footer />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders children correctly', () => {
Expand Down
1 change: 1 addition & 0 deletions f2/src/components/layout/__tests__/Layout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, cleanup } from '@testing-library/react'
import { Layout } from '..'

describe('<Layout />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders', () => {
Expand Down
7 changes: 6 additions & 1 deletion f2/src/components/layout/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useEffect } from 'react'
import PropTypes from 'prop-types'
import { Container } from '../container'

Expand All @@ -10,6 +10,11 @@ export const Layout = ({ fluid, columns, ...props }) => {
xl: columns.xl * 100 + '%',
}

// scroll to the top of the page when this Layout renders
useEffect(() => {
window.scrollTo(0, 0)
})

return (
<Container
{...(fluid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<PhaseBanner />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('properly renders alpha banner', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ i18n.load('en', { en })
i18n.activate('en')

describe('<WarningBanner />', () => {
beforeEach(() => (global.scrollTo = jest.fn()))
afterEach(cleanup)

it('renders correctly', () => {
Expand Down

0 comments on commit ba62046

Please sign in to comment.