methods-test.js
1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* methods-test.js: Tests for HTTP methods.
*
* (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors.
* MIT LICENSE
*
*/
var assert = require('assert'),
vows = require('vows'),
director = require('../../../lib/director');
vows.describe('director/http/methods').addBatch({
"When using director": {
"an instance of director.http.Router should have all relevant RFC methods": function () {
var router = new director.http.Router();
director.http.methods.forEach(function (method) {
assert.isFunction(router[method.toLowerCase()]);
});
},
"the path() method": {
topic: new director.http.Router(),
"/resource": {
"should insert nested routes correct": function (router) {
function getResource() {}
function modifyResource() {}
router.path(/\/resource/, function () {
this.get(getResource);
this.put(/\/update/, modifyResource);
this.post(/create/, modifyResource);
});
assert.equal(router.routes.resource.get, getResource);
assert.equal(router.routes.resource.update.put, modifyResource);
assert.equal(router.routes.resource.create.post, modifyResource);
}
}
}
}
}).export(module);