mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-09-12 22:20:09 +02:00
Initial commit
This commit is contained in:
21
src/pages/NotFound/__tests__/NotFound.tsx
Executable file
21
src/pages/NotFound/__tests__/NotFound.tsx
Executable file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
import { render } from "@testing-library/react"
|
||||
import { MemoryRouter } from "react-router-dom"
|
||||
|
||||
import NotFound from "../index"
|
||||
|
||||
describe("<NotFound />", () => {
|
||||
it("renders", () => {
|
||||
const tree = render(
|
||||
<MemoryRouter>
|
||||
{/*
|
||||
@ts-expect-error */}
|
||||
<NotFound />
|
||||
</MemoryRouter>
|
||||
).container.firstChild
|
||||
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
})
|
11
src/pages/NotFound/__tests__/__snapshots__/NotFound.tsx.snap
Normal file
11
src/pages/NotFound/__tests__/__snapshots__/NotFound.tsx.snap
Normal file
@@ -0,0 +1,11 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<NotFound /> renders 1`] = `
|
||||
<div
|
||||
class="NotFound"
|
||||
>
|
||||
<p>
|
||||
Oops, Page was not found!
|
||||
</p>
|
||||
</div>
|
||||
`;
|
23
src/pages/NotFound/index.tsx
Executable file
23
src/pages/NotFound/index.tsx
Executable file
@@ -0,0 +1,23 @@
|
||||
import { memo } from "react"
|
||||
import { RouteComponentProps } from "react-router-dom"
|
||||
import { Helmet } from "react-helmet"
|
||||
|
||||
import styles from "./styles.module.scss"
|
||||
|
||||
type Props = RouteComponentProps
|
||||
|
||||
const NotFound = ({ staticContext }: Props) => {
|
||||
// We have to check if staticContext exists
|
||||
// because it will be undefined if rendered through a BrowserRoute
|
||||
/* istanbul ignore next */
|
||||
if (staticContext) staticContext.statusCode = 404
|
||||
|
||||
return (
|
||||
<div className={styles.NotFound}>
|
||||
<Helmet title="Oops" />
|
||||
<p>Oops, Page was not found!</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default memo(NotFound)
|
3
src/pages/NotFound/styles.module.scss
Executable file
3
src/pages/NotFound/styles.module.scss
Executable file
@@ -0,0 +1,3 @@
|
||||
.NotFound {
|
||||
padding: 0 15px;
|
||||
}
|
Reference in New Issue
Block a user