mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
31bca0052f
Introduces 'series' and 'seriesPart' fields to the Audiobook model and database schema. Updates API routes, file organization, and path template utilities to support series metadata. Enhances chapter merging logic, improves notification backend testing, and expands test coverage for admin and API routes.
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
/**
|
|
* Component: Next Navigation Test Mock
|
|
* Documentation: documentation/frontend/routing-auth.md
|
|
*/
|
|
|
|
import { vi } from 'vitest';
|
|
|
|
const router = vi.hoisted(() => ({
|
|
push: vi.fn(),
|
|
replace: vi.fn(),
|
|
prefetch: vi.fn(),
|
|
refresh: vi.fn(),
|
|
back: vi.fn(),
|
|
forward: vi.fn(),
|
|
}));
|
|
|
|
let pathname = '/';
|
|
let searchParams = new URLSearchParams();
|
|
|
|
export const routerMock = router;
|
|
|
|
export const setMockPathname = (value: string) => {
|
|
pathname = value;
|
|
};
|
|
|
|
export const setMockSearchParams = (value: string | URLSearchParams) => {
|
|
searchParams = typeof value === 'string' ? new URLSearchParams(value) : value;
|
|
};
|
|
|
|
export const resetMockRouter = () => {
|
|
router.push.mockReset();
|
|
router.replace.mockReset();
|
|
router.prefetch.mockReset();
|
|
router.refresh.mockReset();
|
|
router.back.mockReset();
|
|
router.forward.mockReset();
|
|
pathname = '/';
|
|
searchParams = new URLSearchParams();
|
|
};
|
|
|
|
vi.mock('next/navigation', () => ({
|
|
useRouter: () => router,
|
|
usePathname: () => pathname,
|
|
useSearchParams: () => searchParams,
|
|
redirect: vi.fn(),
|
|
notFound: vi.fn(),
|
|
}));
|