diff --git a/test/lib-http-proxy-test.js b/test/lib-http-proxy-test.js index 5252300..e087ebd 100644 --- a/test/lib-http-proxy-test.js +++ b/test/lib-http-proxy-test.js @@ -336,6 +336,7 @@ describe('lib/http-proxy.js', function() { }); }); + it('should proxy a socket.io stream', function (done) { var ports = { source: gen.port, proxy: gen.port }, proxy = httpProxy.createProxyServer({ @@ -370,5 +371,36 @@ describe('lib/http-proxy.js', function() { }); }) }); + + + it('should emit close event when socket.io client disconnects', function (done) { + var ports = { source: gen.port, proxy: gen.port }; + var proxy = httpProxy.createProxyServer({ + target: 'ws://127.0.0.1:' + ports.source, + ws: true + }); + proxyServer = proxy.listen(ports.proxy); + var server = http.createServer(); + destiny = io.listen(server); + + function startSocketIo() { + var client = ioClient.connect('ws://127.0.0.1:' + ports.proxy); + client.on('connect', function () { + client.disconnect(); + }); + } + + proxyServer.on('close', function() { + proxyServer.close(); + server.close(); + done(); + }); + + server.listen(ports.source); + server.on('listening', startSocketIo); + + }); + + }) });