File size: 1,735 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
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')
})
})
|