next.js/packages/next/src/client/components/router-reducer/compute-changed-path.test.ts
compute-changed-path.test.ts62 lines1.5 KB
import { computeChangedPath } from './compute-changed-path'
import { PrefetchHint } from '../../../shared/lib/app-router-types'

describe('computeChangedPath', () => {
  it('should return the correct path', () => {
    expect(
      computeChangedPath(
        [
          '',
          {
            children: [
              '(marketing)',
              {
                children: ['__PAGE__', {}],
                modal: [
                  '(...)stats',
                  {
                    children: [
                      ['key', 'github', 'd', null],
                      {
                        children: ['__PAGE__', {}],
                      },
                    ],
                  },
                ],
              },
            ],
          },
          undefined,
          undefined,
          PrefetchHint.IsRootLayout,
        ],
        [
          '',
          {
            children: [
              '(marketing)',
              {
                children: ['__PAGE__', {}],
                modal: [
                  '(...)stats',
                  {
                    children: [
                      ['key', 'github', 'd', null],
                      {
                        children: ['__PAGE__', {}],
                      },
                    ],
                  },
                ],
              },
            ],
          },
          undefined,
          undefined,
          PrefetchHint.IsRootLayout,
        ]
      )
    ).toBe('/')
  })
})
Quest for Codev2.0.0
/
SIGN IN