uri_modifier_spec.js
914 Bytes
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
43
44
45
46
var needle = require('../'),
sinon = require('sinon'),
should = require('should'),
http = require('http'),
helpers = require('./helpers');
var port = 3456;
describe('uri_modifier config parameter function', function() {
var server, uri;
function send_request(mw, cb) {
needle.get(uri, { uri_modifier: mw }, cb);
}
before(function(done){
server = helpers.server({ port: port }, done);
})
after(function(done) {
server.close(done);
})
describe('modifies uri', function() {
var path = '/foo/replace';
before(function() {
uri = 'localhost:' + port + path
});
it('should modify path', function(done) {
send_request(function(uri) {
return uri.replace('/replace', '');
}, function(err, res) {
should.not.exist(err);
should(res.req.path).be.exactly('/foo');
done();
});
});
})
})