mirror of https://github.com/jo/docuri.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1014 B
JavaScript
25 lines
1014 B
JavaScript
var test = require('tap').test;
|
|
var docuri = require('..');
|
|
|
|
test('optional parameter', function(t) {
|
|
docuri.route('page(/:id)', 'page');
|
|
|
|
t.deepEqual(docuri.page('page'), {}, 'parsed page returns empty object');
|
|
t.deepEqual(docuri.page('page/mypage'), { id: 'mypage' }, 'parsed page has "id" set to "mypage"');
|
|
t.equal(docuri.page(), 'page', 'stringified empty page results in "page"');
|
|
t.equal(docuri.page({ id: 'mypage' }), 'page/mypage', 'stringified page results in "page/mypage"');
|
|
|
|
t.end();
|
|
});
|
|
|
|
test('surrounded optional parameter', function(t) {
|
|
docuri.route('page(/:id)/suffix', 'page');
|
|
|
|
t.deepEqual(docuri.page('page/suffix'), {}, 'parsed page returns empty object');
|
|
t.deepEqual(docuri.page('page/mypage/suffix'), { id: 'mypage' }, 'parsed page has "id" set to "mypage"');
|
|
t.equal(docuri.page(), 'page/suffix', 'stringified empty page results in "page"');
|
|
t.equal(docuri.page({ id: 'mypage' }), 'page/mypage/suffix', 'stringified page results in "page/mypage"');
|
|
|
|
t.end();
|
|
});
|