Skip to content

Commit 1d1ee88

Browse files
committed
[tests] the options got a problem and this test probe that timeout is not being set
1 parent e445013 commit 1d1ee88

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

test/lib-http-proxy-test.js

+37-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('lib/http-proxy.js', function() {
126126
done();
127127
})
128128

129-
var proxyServer = proxy.listen('8081');
129+
proxy.listen('8081');
130130

131131
http.request({
132132
hostname: '127.0.0.1',
@@ -136,6 +136,38 @@ describe('lib/http-proxy.js', function() {
136136
});
137137
});
138138

139+
describe('#createProxyServer setting the correct timeout value', function () {
140+
it('should hang up the socket at the timeout', function (done) {
141+
this.timeout(30);
142+
var proxy = httpProxy.createProxyServer({
143+
target: 'http://127.0.0.1:8080',
144+
timeout: 3
145+
}).listen('8081');
146+
147+
var source = http.createServer(function(req, res) {
148+
setTimeout(function () {
149+
res.end('At this point the socket should be closed');
150+
}, 5)
151+
});
152+
153+
source.listen('8080');
154+
155+
var testReq = http.request({
156+
hostname: '127.0.0.1',
157+
port: '8081',
158+
method: 'GET',
159+
}, function() {});
160+
161+
testReq.on('error', function (e) {
162+
expect(e).to.be.an(Error);
163+
expect(e.code).to.be.eql('ECONNRESET');
164+
done();
165+
});
166+
167+
testReq.end();
168+
})
169+
})
170+
139171
// describe('#createProxyServer using the web-incoming passes', function () {
140172
// it('should emit events correclty', function(done) {
141173
// var proxy = httpProxy.createProxyServer({
@@ -244,3 +276,7 @@ describe('lib/http-proxy.js', function() {
244276
});
245277
})
246278
});
279+
280+
describe('#createProxyServer using the ws-incoming passes', function () {
281+
it('should call the callback with the error');
282+
})

0 commit comments

Comments
 (0)