generated from DTS-STN/next-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into snyk-upgrade-7cb7d96991fec278ac99495cb11c0898
- Loading branch information
Showing
36 changed files
with
725 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom/extend-expect' | ||
import { axe, toHaveNoViolations } from 'jest-axe' | ||
import { Date } from '../../components/Date' | ||
|
||
expect.extend(toHaveNoViolations) | ||
|
||
describe('Date', () => { | ||
it('renders Date', () => { | ||
render(<Date id="testID" date="20230331T00001" label="label" />) | ||
const title = screen.getByTestId('testID') | ||
const caption = screen.getByText('20230331') | ||
const label = screen.getByText('label') | ||
expect(title).toBeInTheDocument() | ||
expect(caption).toBeInTheDocument() | ||
expect(label).toBeInTheDocument() | ||
}) | ||
|
||
it('has no a11y viollations', async () => { | ||
const { container } = render(<Date id="testID" date="20230331" />) | ||
const results = await axe(container) | ||
expect(results).toHaveNoViolations() | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
import { render } from '@testing-library/react' | ||
import '@testing-library/jest-dom/extend-expect' | ||
import { ErrorPage } from '../../components/ErrorPage.js' | ||
import { axe, toHaveNoViolations } from 'jest-axe' | ||
|
||
expect.extend(toHaveNoViolations) | ||
|
||
describe('Error Pages', () => { | ||
it('has no a11y violations 404', async () => { | ||
const { container } = render(<ErrorPage lang="en" errType="404" isAuth />) | ||
const results = await axe(container) | ||
expect(results).toHaveNoViolations() | ||
}) | ||
|
||
it('has no a11y violations 500', async () => { | ||
const { container } = render(<ErrorPage lang="en" errType="500" isAuth />) | ||
const results = await axe(container) | ||
expect(results).toHaveNoViolations() | ||
}) | ||
|
||
it('has no a11y violations 503', async () => { | ||
const { container } = render(<ErrorPage lang="en" errType="503" isAuth />) | ||
const results = await axe(container) | ||
expect(results).toHaveNoViolations() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom/extend-expect' | ||
import { axe, toHaveNoViolations } from 'jest-axe' | ||
import LoadingSpinner from '../../components/LoadingSpinner' | ||
|
||
expect.extend(toHaveNoViolations) | ||
|
||
describe('LoadingSpinner', () => { | ||
it('renders the LoadingSpinner', () => { | ||
const { container } = render( | ||
<LoadingSpinner dataTestid="loading-spinner" text={'Loading'} /> | ||
) | ||
expect(container).toBeTruthy() | ||
const text = screen.getByText('Loading') | ||
expect(text).toBeInTheDocument() | ||
}) | ||
|
||
it('has no a11y viollations', async () => { | ||
const { container } = render( | ||
<LoadingSpinner dataTestid={'loading-spinner'} text={'loading'} /> | ||
) | ||
const results = await axe(container) | ||
expect(results).toHaveNoViolations() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom/extend-expect' | ||
import { axe, toHaveNoViolations } from 'jest-axe' | ||
import TableContents from '../../components/TableContents' | ||
|
||
expect.extend(toHaveNoViolations) | ||
|
||
describe('TableContents', () => { | ||
const { container } = render( | ||
<TableContents | ||
locale="en" | ||
sectionList={[ | ||
{ | ||
name: 'Telephone', | ||
link: '#telephone', | ||
}, | ||
{ | ||
name: 'Callback', | ||
link: '#callback', | ||
}, | ||
]} | ||
/> | ||
) | ||
it('renders TableContents', () => { | ||
const listitem1 = screen.getByText('Telephone') | ||
const listitem2 = screen.getByText('Callback') | ||
expect(listitem1).toBeInTheDocument() | ||
expect(listitem2).toBeInTheDocument() | ||
}) | ||
|
||
it('has no a11y viollations', async () => { | ||
const results = await axe(container) | ||
expect(results).toHaveNoViolations() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import Custom500 from '../../pages/500' | ||
|
||
jest.mock('../../graphql/mappers/beta-banner-opt-out', () => ({ | ||
getBetaBannerContent: () => { | ||
return new Promise(function (resolve, reject) { | ||
resolve({ | ||
en: {}, | ||
fr: {}, | ||
}) | ||
}) | ||
}, | ||
})) | ||
|
||
jest.mock('../../graphql/mappers/beta-popup-exit', () => ({ | ||
getBetaPopupExitContent: () => { | ||
return new Promise(function (resolve, reject) { | ||
resolve({ en: {}, fr: {} }) | ||
}) | ||
}, | ||
})) | ||
|
||
describe('custom error', () => { | ||
it('renders custom statusCode 500 without crashing', () => { | ||
render( | ||
<Custom500 | ||
lang="en" | ||
errType="500" | ||
isAuth={false} | ||
homePageLink={'/en/my-dashboard'} | ||
accountPageLink="/" | ||
/> | ||
) | ||
const element = screen.getByTestId('errorType') | ||
expect(element.textContent).toEqual('Error 500') | ||
}) | ||
|
||
it('renders custom error page in french without crashing', () => { | ||
render( | ||
<Custom500 | ||
lang="fr" | ||
errType="500" | ||
isAuth={false} | ||
homePageLink={'/fr/my-dashboard'} | ||
accountPageLink="/" | ||
/> | ||
) | ||
const element = screen.getByTestId('errorType') | ||
expect(element.textContent).toEqual('Erreur 500') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import PropTypes from 'prop-types' | ||
|
||
export function Date(props) { | ||
const { id, label, date } = props | ||
const dateFormatted = date ? date.split('T')[0] : 'NA' | ||
return ( | ||
<dl id={id} data-testid={id} className="mt-8 py-2 font-body"> | ||
<dt className="inline">{label}</dt> | ||
<dd className="inline"> | ||
{dateFormatted === 'NA' ? ( | ||
<time>{` ${dateFormatted}`}</time> | ||
) : ( | ||
<time dateTime={dateFormatted}>{` ${dateFormatted}`}</time> | ||
)} | ||
</dd> | ||
</dl> | ||
) | ||
} | ||
|
||
Date.propTypes = { | ||
/** | ||
* component id | ||
*/ | ||
id: PropTypes.string, | ||
|
||
/** | ||
* Text to show before date, defaults to "Date Modified: " | ||
*/ | ||
label: PropTypes.string, | ||
|
||
/** | ||
* Date string in format yyyyMMdd | ||
*/ | ||
date: PropTypes.string, | ||
} |
Oops, something went wrong.