forked from SCOAP3/scoap3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
49 changed files
with
7,679 additions
and
246 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import nextJest from 'next/jest.js' | ||
|
||
const createJestConfig = nextJest({ | ||
dir: './', | ||
}) | ||
|
||
/** @type {import('jest').Config} */ | ||
const config = { | ||
setupFilesAfterEnv: ['./jest.setup.ts'], | ||
testEnvironment: 'jest-environment-jsdom', | ||
} | ||
|
||
export default createJestConfig(config) |
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,26 @@ | ||
import '@testing-library/jest-dom'; | ||
|
||
Object.defineProperty(window, 'matchMedia', { | ||
writable: true, | ||
value: jest.fn().mockImplementation(query => ({ | ||
matches: false, | ||
media: query, | ||
onchange: null, | ||
addListener: jest.fn(), // Deprecated | ||
removeListener: jest.fn(), // Deprecated | ||
addEventListener: jest.fn(), | ||
removeEventListener: jest.fn(), | ||
dispatchEvent: jest.fn(), | ||
})), | ||
}); | ||
|
||
jest.mock("next/navigation", () => { | ||
return { | ||
useRouter: jest.fn(() => ({ | ||
push: jest.fn(), | ||
})), | ||
useSearchParams: jest.fn(() => ({ | ||
get: jest.fn(), | ||
})), | ||
}; | ||
}); |
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,12 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
import PageNotFound from "@/pages/404"; | ||
|
||
describe("PageNotFound", () => { | ||
it("renders 404 page", () => { | ||
const { container } = render(<PageNotFound />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
expect(screen.getByText("Page not found")).toBeInTheDocument(); | ||
}); | ||
}); |
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,32 @@ | ||
import React from "react"; | ||
import { render, screen, fireEvent } from "@testing-library/react"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
import ServerErrorPage from "@/pages/500"; | ||
|
||
jest.mock("next/navigation", () => ({ | ||
useRouter: jest.fn(), | ||
})); | ||
|
||
const mockPush = jest.fn(); | ||
(useRouter as jest.Mock).mockImplementation(() => ({ | ||
push: mockPush, | ||
})); | ||
|
||
describe("ServerErrorPage", () => { | ||
it("renders error page", () => { | ||
const { container } = render(<ServerErrorPage />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
expect(screen.getByText("Something went wrong")).toBeInTheDocument(); | ||
expect(screen.getByTestId("go-back")).toBeInTheDocument(); | ||
}); | ||
|
||
it("triggers router.push on 'go to home page' button click", () => { | ||
render(<ServerErrorPage />); | ||
|
||
fireEvent.click(screen.getByTestId("go-back")); | ||
|
||
expect(mockPush).toHaveBeenCalledWith("/"); | ||
}); | ||
}); |
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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PageNotFound renders 404 page 1`] = ` | ||
<div> | ||
<div | ||
class="error-page" | ||
> | ||
<span | ||
aria-label="search" | ||
class="anticon anticon-search" | ||
role="img" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
data-icon="search" | ||
fill="currentColor" | ||
focusable="false" | ||
height="1em" | ||
viewBox="64 64 896 896" | ||
width="1em" | ||
> | ||
<path | ||
d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z" | ||
/> | ||
</svg> | ||
</span> | ||
<h1> | ||
Page not found | ||
</h1> | ||
<p> | ||
The page you are looking for could not be found. | ||
</p> | ||
</div> | ||
</div> | ||
`; |
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,45 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ServerErrorPage renders error page 1`] = ` | ||
<div> | ||
<div | ||
class="error-page" | ||
> | ||
<span | ||
aria-label="exclamation-circle" | ||
class="anticon anticon-exclamation-circle" | ||
role="img" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
data-icon="exclamation-circle" | ||
fill="currentColor" | ||
focusable="false" | ||
height="1em" | ||
viewBox="64 64 896 896" | ||
width="1em" | ||
> | ||
<path | ||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" | ||
/> | ||
<path | ||
d="M464 688a48 48 0 1096 0 48 48 0 10-96 0zm24-112h48c4.4 0 8-3.6 8-8V296c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8z" | ||
/> | ||
</svg> | ||
</span> | ||
<h1> | ||
Something went wrong | ||
</h1> | ||
<p> | ||
Please try again later or | ||
<a | ||
data-testid="go-back" | ||
type="button" | ||
> | ||
go to home page | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
`; |
Oops, something went wrong.