File size: 954 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
import { PAGE_TYPES } from '../../lib/page-types'
import { AbsoluteFilenameNormalizer } from './absolute-filename-normalizer'

describe('AbsoluteFilenameNormalizer', () => {
  it.each([
    {
      name: PAGE_TYPES.APP,
      pathname: '<root>/app/basic/(grouped)/endpoint/nested/route.ts',
      expected: '/basic/(grouped)/endpoint/nested/route',
    },
    {
      name: PAGE_TYPES.PAGES,
      pathname: '<root>/pages/basic/endpoint/nested.ts',
      expected: '/basic/endpoint/nested',
    },
    {
      name: PAGE_TYPES.PAGES,
      pathname: '<root>/pages/basic/endpoint/index.ts',
      expected: '/basic/endpoint',
    },
  ])(
    "normalizes '$pathname' to '$expected'",
    ({ pathname, expected, name }) => {
      const normalizer = new AbsoluteFilenameNormalizer(
        `<root>/${name}`,
        ['ts', 'tsx', 'js', 'jsx'],
        name as PAGE_TYPES
      )

      expect(normalizer.normalize(pathname)).toEqual(expected)
    }
  )
})