From 74710d7cca3aa8ba71d268f41875a6bd6875760e Mon Sep 17 00:00:00 2001 From: paolo-delmundo Date: Sat, 21 Mar 2015 23:48:52 -0400 Subject: [PATCH] Added removeHandlers Test for removeHandlers Minor bump in package.json --- lib/proxy.js | 6 +++++- package.json | 2 +- tests/registerHandler-test.js | 17 ++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/proxy.js b/lib/proxy.js index 44c1307..baae177 100644 --- a/lib/proxy.js +++ b/lib/proxy.js @@ -230,9 +230,13 @@ ProxyServer.prototype.removeHandler = function() { return this; }; +ProxyServer.prototype.removeHandlers = function() { + this.handlers = []; +}; + exports.createServer = function (options) { return new ProxyServer(options); -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index fd3d26d..509a950 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "intercept-proxy", "description": "A light weight proxy for exposing a remote site through localhost and replace select resources with local versions for testing and development purposes.", - "version": "0.3.3", + "version": "0.4.0", "authors": [ "Johan Öbrink (https://github.com/johanobrink)" ], diff --git a/tests/registerHandler-test.js b/tests/registerHandler-test.js index e1ce83e..059eff0 100644 --- a/tests/registerHandler-test.js +++ b/tests/registerHandler-test.js @@ -86,6 +86,21 @@ describe('handlers', function() { expect(server.handlers['/foo']['PUT']).to.equal(handler); }); + it('should remove all handlers', function() { + var handler = function(req, res) {}; + + server.addHandler('/foo', 'GET', handler); + server.addHandler('/foo2', 'GET', handler); + + expect(server.handlers['/foo']['GET']).to.equal(handler); + expect(server.handlers['/foo2']['GET']).to.equal(handler); + + server.removeHandlers(); + + expect(server.handlers['/foo']).to.be.undefined; + expect(server.handlers['/foo2']).to.be.undefined; + }); + describe('calls to handlers', function() { it('should call a handler for matching path', function(done) { @@ -132,4 +147,4 @@ describe('handlers', function() { }); -}); \ No newline at end of file +});