uri_modifier_spec.js 914 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. var needle = require('../'),
  2. sinon = require('sinon'),
  3. should = require('should'),
  4. http = require('http'),
  5. helpers = require('./helpers');
  6. var port = 3456;
  7. describe('uri_modifier config parameter function', function() {
  8. var server, uri;
  9. function send_request(mw, cb) {
  10. needle.get(uri, { uri_modifier: mw }, cb);
  11. }
  12. before(function(done){
  13. server = helpers.server({ port: port }, done);
  14. })
  15. after(function(done) {
  16. server.close(done);
  17. })
  18. describe('modifies uri', function() {
  19. var path = '/foo/replace';
  20. before(function() {
  21. uri = 'localhost:' + port + path
  22. });
  23. it('should modify path', function(done) {
  24. send_request(function(uri) {
  25. return uri.replace('/replace', '');
  26. }, function(err, res) {
  27. should.not.exist(err);
  28. should(res.req.path).be.exactly('/foo');
  29. done();
  30. });
  31. });
  32. })
  33. })