Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50675 views
1
/*
2
* dispatch-test.js: Tests for the core dispatch method.
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var assert = require('assert'),
10
vows = require('vows'),
11
director = require('../../../lib/director');
12
13
vows.describe('director/cli/path').addBatch({
14
"An instance of director.cli.Router": {
15
topic: new director.cli.Router(),
16
"the path() method": {
17
"should create the correct nested routing table": function (router) {
18
function noop () {}
19
20
router.path(/apps/, function () {
21
router.path(/foo/, function () {
22
router.on(/bar/, noop);
23
});
24
25
router.on(/list/, noop);
26
});
27
28
router.on(/users/, noop);
29
30
assert.isObject(router.routes.apps);
31
assert.isFunction(router.routes.apps.list.on);
32
assert.isObject(router.routes.apps.foo);
33
assert.isFunction(router.routes.apps.foo.bar.on);
34
assert.isFunction(router.routes.users.on);
35
}
36
}
37
}
38
}).export(module);
39
40
41