-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab96c9b
commit 8019695
Showing
9 changed files
with
174 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Toaster } from "@/components/ui/toaster"; | ||
import { TooltipProvider } from "@/components/ui/tooltip"; | ||
import { type JSX, type ReactNode } from "react"; | ||
|
||
type ProvidersProps = { | ||
readonly children: ReactNode; | ||
}; | ||
export const Providers = ({ children }: ProvidersProps): JSX.Element => ( | ||
<TooltipProvider> | ||
{children} | ||
<Toaster /> | ||
</TooltipProvider> | ||
); |
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 { Providers } from "@/components/providers"; | ||
import { routes } from "@/routes"; | ||
import { | ||
render as reactTestingLibraryRender, | ||
type RenderOptions, | ||
} from "@testing-library/react"; | ||
import { type ReactElement } from "react"; | ||
import { createMemoryRouter, RouterProvider } from "react-router-dom"; | ||
|
||
const customRender = ( | ||
ui: ReactElement, | ||
options?: Omit<RenderOptions, "wrapper">, | ||
): ReturnType<typeof reactTestingLibraryRender> => | ||
reactTestingLibraryRender(ui, { wrapper: Providers, ...options }); | ||
|
||
// eslint-disable-next-line import/export | ||
export * from "@testing-library/react"; | ||
// eslint-disable-next-line import/export | ||
export { customRender as render }; | ||
|
||
export const renderWithRouter = (): ReturnType< | ||
typeof reactTestingLibraryRender | ||
> => { | ||
const router = createMemoryRouter(routes); | ||
return customRender(<RouterProvider router={router} />); | ||
}; |
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 |
---|---|---|
@@ -1,20 +1,17 @@ | ||
import "./index.css"; | ||
import { App } from "./app"; | ||
// eslint-disable-next-line import/default | ||
import React from "react"; | ||
import { Providers } from "@/components/providers"; | ||
import { routes } from "@/routes"; | ||
import { StrictMode } from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
import { createBrowserRouter, RouterProvider } from "react-router-dom"; | ||
|
||
const router = createBrowserRouter([ | ||
{ | ||
element: <App />, | ||
path: "/", | ||
}, | ||
]); | ||
const router = createBrowserRouter(routes); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
createRoot(document.querySelector("#root")!).render( | ||
<React.StrictMode> | ||
<RouterProvider router={router} /> | ||
</React.StrictMode>, | ||
<StrictMode> | ||
<Providers> | ||
<RouterProvider router={router} /> | ||
</Providers> | ||
</StrictMode>, | ||
); |
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,8 @@ | ||
import { App } from "@/app"; | ||
|
||
export const routes = [ | ||
{ | ||
element: <App />, | ||
path: "/", | ||
}, | ||
]; |
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,8 @@ | ||
// eslint-disable-next-line import/no-unassigned-import | ||
import "@testing-library/jest-dom/vitest"; | ||
import { cleanup } from "./src/lib/test-utils"; | ||
import { afterEach } from "vitest"; | ||
|
||
afterEach(() => { | ||
cleanup(); | ||
}); |