Skip to content

Commit 5407789

Browse files
committed
use tape in test/misc.coffee
1 parent 21e1995 commit 5407789

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

test/misc.coffee

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1+
test = require 'tape'
12
UrlPattern = require '../lib/url-pattern'
23

3-
module.exports =
4+
test 'instance of UrlPattern is handled correctly as constructor argument', (t) ->
5+
pattern = new UrlPattern '/user/:userId/task/:taskId'
6+
copy = new UrlPattern pattern
7+
t.deepEqual copy.match('/user/10/task/52'),
8+
userId: '10'
9+
taskId: '52'
10+
t.end()
411

5-
'instance of UrlPattern is handled correctly as constructor argument': (test) ->
6-
pattern = new UrlPattern '/user/:userId/task/:taskId'
7-
copy = new UrlPattern pattern
8-
test.deepEqual copy.match('/user/10/task/52'),
9-
userId: '10'
10-
taskId: '52'
11-
test.done()
12+
test 'match full stops in segment values', (t) ->
13+
options =
14+
segmentValueCharset: 'a-zA-Z0-9-_ %.'
15+
pattern = new UrlPattern '/api/v1/user/:id/', options
16+
t.deepEqual pattern.match('/api/v1/user/test.name/'),
17+
id: 'test.name'
18+
t.end()
1219

13-
'match full stops in segment values': (test) ->
14-
options =
15-
segmentValueCharset: 'a-zA-Z0-9-_ %.'
16-
pattern = new UrlPattern '/api/v1/user/:id/', options
17-
test.deepEqual pattern.match('/api/v1/user/test.name/'),
18-
id: 'test.name'
19-
test.done()
20-
21-
'regex group names': (test) ->
22-
pattern = new UrlPattern /^\/api\/([a-zA-Z0-9-_~ %]+)(?:\/(\d+))?$/, ['resource', 'id']
23-
test.deepEqual pattern.match('/api/users'),
24-
resource: 'users'
25-
test.equal pattern.match('/apiii/users'), null
26-
test.deepEqual pattern.match('/api/users/foo'), null
27-
test.deepEqual pattern.match('/api/users/10'),
28-
resource: 'users'
29-
id: '10'
30-
test.deepEqual pattern.match('/api/projects/10/'), null
31-
test.done()
20+
test 'regex group names', (t) ->
21+
pattern = new UrlPattern /^\/api\/([a-zA-Z0-9-_~ %]+)(?:\/(\d+))?$/, ['resource', 'id']
22+
t.deepEqual pattern.match('/api/users'),
23+
resource: 'users'
24+
t.equal pattern.match('/apiii/users'), null
25+
t.deepEqual pattern.match('/api/users/foo'), null
26+
t.deepEqual pattern.match('/api/users/10'),
27+
resource: 'users'
28+
id: '10'
29+
t.deepEqual pattern.match('/api/projects/10/'), null
30+
t.end()

0 commit comments

Comments
 (0)