Skip to content

Commit

Permalink
Updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
delvedor committed Jan 27, 2018
1 parent f2f5438 commit 95a44f0
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/max-param-length.test.js
@@ -0,0 +1,45 @@
'use strict'

const t = require('tap')
const test = t.test
const FindMyWay = require('../')

test('maxParamLength default value is 500', t => {
t.plan(1)

const findMyWay = FindMyWay()
t.strictEqual(findMyWay.maxParamLength, 500)
})

test('maxParamLength should set the maximum length for a parametric route', t => {
t.plan(1)

const findMyWay = FindMyWay({ maxParamLength: 10 })
findMyWay.on('GET', '/test/:param', () => {})
t.deepEqual(findMyWay.find('GET', '/test/123456789abcd'), null)
})

test('maxParamLength should set the maximum length for a parametric (regex) route', t => {
t.plan(1)

const findMyWay = FindMyWay({ maxParamLength: 10 })
findMyWay.on('GET', '/test/:param(^\\d+$)', () => {})

t.deepEqual(findMyWay.find('GET', '/test/123456789abcd'), null)
})

test('maxParamLength should set the maximum length for a parametric (multi) route', t => {
t.plan(1)

const findMyWay = FindMyWay({ maxParamLength: 10 })
findMyWay.on('GET', '/test/:param-bar', () => {})
t.deepEqual(findMyWay.find('GET', '/test/123456789abcd'), null)
})

test('maxParamLength should set the maximum length for a parametric (regex with suffix) route', t => {
t.plan(1)

const findMyWay = FindMyWay({ maxParamLength: 10 })
findMyWay.on('GET', '/test/:param(^\\w{3})bar', () => {})
t.deepEqual(findMyWay.find('GET', '/test/123456789abcd'), null)
})

0 comments on commit 95a44f0

Please sign in to comment.