Skip to content
Myr

router.test.ts

This file

Path

src/router/pattern-router/router.test.ts

42 lines · 1.1 KiB · TypeScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than f0b094d point at it.

Merge commit from forkYusuke Wadabefore adoptionf0b094d

lines 1–42why, one step back
1import { UnsupportedPathError } from '../../router'
2import { runTest } from '../common.case.test'3import { PatternRouter } from './router'45describe('Pattern', () => {6 runTest({7 skip: [8 {9 reason: 'UnsupportedPath',10 tests: ['Duplicate param name > self'],11 },12 {13 reason: 'PatternRouter allows trailing slashes',14 tests: ['Trailing slash > GET /book/'],15 },16 ],17 newRouter: () => new PatternRouter(),18 })1920 describe('Duplicate param name', () => {21 it('self', () => {22 const router = new PatternRouter<string>()23 expect(() => {24 router.add('GET', '/:id/:id', 'foo')25 }).toThrowError(UnsupportedPathError)26 })27 })28 describe('Trailing slash', () => {29 const router = new PatternRouter<string>()3031 beforeEach(() => {32 router.add('GET', '/book', 'GET /book')33 router.add('GET', '/book/:id', 'GET /book/:id')34 })3536 it('GET /book/', () => {37 const [res] = router.match('GET', '/book/')38 expect(res.length).toBe(1)39 expect(res[0][0]).toBe('GET /book')40 })41 })42})