File size: 847 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 { toRoute } from './to-route'

describe('toRoute Function', () => {
  it('should remove trailing slash', () => {
    const result = toRoute('/example/')
    expect(result).toBe('/example')
  })

  it('should remove trailing `/index`', () => {
    const result = toRoute('/example/index')
    expect(result).toBe('/example')
  })

  it('should return `/` when input is `/index`', () => {
    const result = toRoute('/index')
    expect(result).toBe('/')
  })

  it('should return `/` when input is `/index/`', () => {
    const result = toRoute('/index/')
    expect(result).toBe('/')
  })

  it('should return `/` when input is only a slash', () => {
    const result = toRoute('/')
    expect(result).toBe('/')
  })

  it('should return `/` when input is empty', () => {
    const result = toRoute('')
    expect(result).toBe('/')
  })
})