File size: 1,570 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
import { isDynamicRoute } from './is-dynamic'

describe('isDynamicRoute', () => {
  describe('strict', () => {
    it('should return true for dynamic routes', () => {
      expect(isDynamicRoute('/blog/[...slug]')).toBe(true)
    })

    it('should return false for static routes', () => {
      expect(isDynamicRoute('/blog/123')).toBe(false)
    })

    it('should return true for dynamic routes with a suffix', () => {
      expect(isDynamicRoute('/blog/[slug].json')).toBe(false)
    })

    it('should return false for dynamic routes with a prefix', () => {
      expect(isDynamicRoute('/blog/$d$slug$[...slug]/')).toBe(false)
    })

    it('should return false for dynamic routes with a suffix and prefix', () => {
      expect(isDynamicRoute('/blog/$d$slug$[...slug].json')).toBe(false)
    })
  })

  describe('non-strict', () => {
    it('should return true for dynamic routes', () => {
      expect(isDynamicRoute('/blog/[...slug]', false)).toBe(true)
    })

    it('should return false for static routes', () => {
      expect(isDynamicRoute('/blog/123', false)).toBe(false)
    })

    it('should return true for dynamic routes with a suffix', () => {
      expect(isDynamicRoute('/blog/[slug].json', false)).toBe(true)
    })

    it('should return true for dynamic routes with a prefix', () => {
      expect(isDynamicRoute('/blog/$d$slug$[...slug]/', false)).toBe(true)
    })

    it('should return true for dynamic routes with a suffix and prefix', () => {
      expect(isDynamicRoute('/blog/$d$slug$[...slug].json', false)).toBe(true)
    })
  })
})