diff --git a/web/src/test/__mocks__/next-link.tsx b/web/src/test/__mocks__/next-link.tsx new file mode 100644 index 0000000..13b43cf --- /dev/null +++ b/web/src/test/__mocks__/next-link.tsx @@ -0,0 +1,5 @@ +import * as React from 'react'; + +export default function Link({ href, children, ...props }: React.ComponentProps<'a'> & { href: string }) { + return {children}; +} diff --git a/web/src/test/__mocks__/next-navigation.ts b/web/src/test/__mocks__/next-navigation.ts new file mode 100644 index 0000000..42c33fa --- /dev/null +++ b/web/src/test/__mocks__/next-navigation.ts @@ -0,0 +1,13 @@ +export const usePathname = () => '/dashboard'; +export const useRouter = () => ({ + push: () => {}, + replace: () => {}, + back: () => {}, + forward: () => {}, + refresh: () => {}, + prefetch: () => {}, +}); +export const useSearchParams = () => new URLSearchParams(); +export const useParams = () => ({}); +export const redirect = () => {}; +export const notFound = () => {}; diff --git a/web/vitest.config.ts b/web/vitest.config.ts index 500890d..7ce5e38 100644 --- a/web/vitest.config.ts +++ b/web/vitest.config.ts @@ -11,6 +11,8 @@ export default defineConfig({ resolve: { alias: { "@": path.resolve(__dirname, "./src"), + "next/navigation": path.resolve(__dirname, "./src/test/__mocks__/next-navigation.ts"), + "next/link": path.resolve(__dirname, "./src/test/__mocks__/next-link.tsx"), }, }, });