newRouter: () => new RegExpRouter(),
})
describe('Return value type', () => {
it('Should return [[T, ParamIndexMap][], ParamStash]', async () => {
it('Should return [[T, ParamIndexMap][], ParamStash]', () => {
const router = new RegExpRouter<string>()
router.add('GET', '/posts/:id', 'get post')
const [res, stash] = router.match('GET', '/posts/1')
router.add('GET', '/:user/entries', 'get user entries')
router.add('GET', '/entry/:name', 'get entry')
router.add('POST', '/entry', 'create entry')
it('GET /entry/entries', async () => {
it('GET /entry/entries', () => {
expect(() => {
router.match('GET', '/entry/entries')
}).toThrowError(UnsupportedPathError)
})
router.add('GET', '/:type/:id', ':type')
router.add('GET', '/:class/:id', ':class')
router.add('GET', '/:model/:id', ':model')
it('GET /entry/123', async () => {
it('GET /entry/123', () => {
expect(() => {
router.match('GET', '/entry/123')
}).toThrowError(UnsupportedPathError)
})