Download next.js/packages/next/src/shared/lib/router/adapters.test.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/adapters.test.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/shared/lib/router/adapters.test.tsx
-
curl -L -o adapters.test.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/shared/lib/router/adapters.test.tsx
1.74 kB
| import type { NextRouter } from './router' | |
| import { adaptForAppRouterInstance } from './adapters' | |
| describe('adaptForAppRouterInstance', () => { | |
| beforeEach(() => jest.resetAllMocks()) | |
| const router = { | |
| back: jest.fn(), | |
| forward: jest.fn(), | |
| reload: jest.fn(), | |
| push: jest.fn(), | |
| replace: jest.fn(), | |
| prefetch: jest.fn(), | |
| } as unknown as NextRouter | |
| const adapter = adaptForAppRouterInstance(router) | |
| it('should forward a call to `back()`', () => { | |
| adapter.back() | |
| expect(router.back).toHaveBeenCalled() | |
| }) | |
| it('should forward a call to `forward()`', () => { | |
| adapter.forward() | |
| expect(router.forward).toHaveBeenCalled() | |
| }) | |
| it('should forward a call to `reload()`', () => { | |
| adapter.refresh() | |
| expect(router.reload).toHaveBeenCalled() | |
| }) | |
| it('should forward a call to `push()`', () => { | |
| adapter.push('/foo') | |
| expect(router.push).toHaveBeenCalledWith('/foo', undefined, { | |
| scroll: undefined, | |
| }) | |
| }) | |
| it('should forward a call to `push()` with options', () => { | |
| adapter.push('/foo', { scroll: false }) | |
| expect(router.push).toHaveBeenCalledWith('/foo', undefined, { | |
| scroll: false, | |
| }) | |
| }) | |
| it('should forward a call to `replace()`', () => { | |
| adapter.replace('/foo') | |
| expect(router.replace).toHaveBeenCalledWith('/foo', undefined, { | |
| scroll: undefined, | |
| }) | |
| }) | |
| it('should forward a call to `replace()` with options', () => { | |
| adapter.replace('/foo', { scroll: false }) | |
| expect(router.replace).toHaveBeenCalledWith('/foo', undefined, { | |
| scroll: false, | |
| }) | |
| }) | |
| it('should forward a call to `prefetch()`', () => { | |
| adapter.prefetch('/foo') | |
| expect(router.prefetch).toHaveBeenCalledWith('/foo') | |
| }) | |
| }) | |