From 2fac7b9b009b12a940efb22de3af6db55ee686a9 Mon Sep 17 00:00:00 2001 From: cronopio Date: Mon, 26 Aug 2013 16:34:32 -0500 Subject: [PATCH] [test] added the lib/caronte/streams/forward.js initial test, one test pending --- lib/caronte/streams/forward.js | 4 ++- test/lib-caronte-streams-forward-test.js | 37 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/lib-caronte-streams-forward-test.js diff --git a/lib/caronte/streams/forward.js b/lib/caronte/streams/forward.js index a3fe955b4..665a91927 100644 --- a/lib/caronte/streams/forward.js +++ b/lib/caronte/streams/forward.js @@ -24,7 +24,9 @@ function ForwardStream(options) { var self = this; self.options = options; - self.res = res; + // To uncomment the line below, please see + // https://github.com/yawnt/caronte/commit/9ab8749a9bec33b49c495975e8364336ad7be1a3#commitcomment-3947117 + //self.res = res; Writable.call(this); diff --git a/test/lib-caronte-streams-forward-test.js b/test/lib-caronte-streams-forward-test.js new file mode 100644 index 000000000..5e74a1efd --- /dev/null +++ b/test/lib-caronte-streams-forward-test.js @@ -0,0 +1,37 @@ +var ForwardStream = require('../lib/caronte/streams/forward'), + expect = require('expect.js'), + Writable = require('stream').Writable, + http = require('http'); + + +describe('lib/caronte/passes/web.js', function () { + describe('forward stream constructor', function () { + it('should be an instance of Writable stream and get the correct options and methods', function () { + var stubOptions = { + key: 'value' + }; + var forwardProxy = new ForwardStream(stubOptions); + + expect(forwardProxy).to.be.a(Writable); + expect(forwardProxy.options).to.eql({ key: 'value' }); + expect(forwardProxy.onPipe).to.be.a('function'); + expect(forwardProxy.onFinish).to.be.a('function'); + expect(forwardProxy._events).to.have.property('pipe'); + expect(forwardProxy._events).to.have.property('finish'); + }); + }); + + describe('should pipe the request and finish it', function () { + it('should make the request on pipe and finish it'); + var stubOptions = { + target: { + hostname : 'www.google.com', + port : '80', + path : '/' + } + }; + + var forwardProxy = new ForwardStream({}); + + }); +}); \ No newline at end of file