Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50675 views
1
/*
2
* methods-test.js: Tests for HTTP methods.
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/http/methods').addBatch({
14
"When using director": {
15
"an instance of director.http.Router should have all relevant RFC methods": function () {
16
var router = new director.http.Router();
17
director.http.methods.forEach(function (method) {
18
assert.isFunction(router[method.toLowerCase()]);
19
});
20
},
21
"the path() method": {
22
topic: new director.http.Router(),
23
"/resource": {
24
"should insert nested routes correct": function (router) {
25
function getResource() {}
26
function modifyResource() {}
27
28
router.path(/\/resource/, function () {
29
this.get(getResource);
30
31
this.put(/\/update/, modifyResource);
32
this.post(/create/, modifyResource);
33
});
34
35
assert.equal(router.routes.resource.get, getResource);
36
assert.equal(router.routes.resource.update.put, modifyResource);
37
assert.equal(router.routes.resource.create.post, modifyResource);
38
}
39
}
40
}
41
}
42
}).export(module);
43