Skip to content

Commit db10c4a

Browse files
committed
[test] Updates for readability
1 parent 1389b70 commit db10c4a

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

test/helpers.js

+29-13
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ TestRunner.prototype.assertProxied = function (host, proxyPort, port, createProx
5959

6060
var test = {
6161
topic: function () {
62-
var that = this, options = {
62+
var that = this,
63+
options;
64+
65+
options = {
6366
method: 'GET',
6467
uri: self.protocol + '://localhost:' + proxyPort,
6568
headers: {
@@ -172,9 +175,9 @@ TestRunner.prototype.webSocketTestWithTable = function (options) {
172175
options.onListen(socket);
173176
}
174177

175-
self.startProxyServerWithTable(
176-
options.ports.proxy,
177-
{router: options.router},
178+
self.startProxyServerWithTable(
179+
options.ports.proxy,
180+
{ router: options.router },
178181
function (err, proxy) {
179182
if (options.onServer) { options.onServer(proxy) }
180183

@@ -213,7 +216,10 @@ TestRunner.prototype.startProxyServer = function (port, targetPort, host, callba
213216
//
214217
TestRunner.prototype.startLatentProxyServer = function (port, targetPort, host, latency, callback) {
215218
// Initialize the nodeProxy and start proxying the request
216-
var that = this, proxyServer = httpProxy.createServer(function (req, res, proxy) {
219+
var that = this,
220+
proxyServer;
221+
222+
proxyServer = httpProxy.createServer(function (req, res, proxy) {
217223
var buffer = proxy.buffer(req);
218224

219225
setTimeout(function () {
@@ -235,7 +241,9 @@ TestRunner.prototype.startLatentProxyServer = function (port, targetPort, host,
235241
// Creates the reverse proxy server with a ProxyTable
236242
//
237243
TestRunner.prototype.startProxyServerWithTable = function (port, options, callback) {
238-
var that = this, proxyServer = httpProxy.createServer(merge({}, options, this.options));
244+
var that = this,
245+
proxyServer = httpProxy.createServer(merge({}, options, this.options));
246+
239247
proxyServer.listen(port, function () {
240248
that.testServers.push(proxyServer);
241249
callback();
@@ -248,10 +256,12 @@ TestRunner.prototype.startProxyServerWithTable = function (port, options, callba
248256
// Creates a latent reverse proxy server using a ProxyTable
249257
//
250258
TestRunner.prototype.startProxyServerWithTableAndLatency = function (port, latency, options, callback) {
259+
//
251260
// Initialize the nodeProxy and start proxying the request
252-
var proxyServer,
253-
that = this,
254-
proxy = new httpProxy.HttpProxy(merge({}, options, that.options));
261+
//
262+
var that = this,
263+
proxy = new httpProxy.HttpProxy(merge({}, options, that.options)),
264+
proxyServer;
255265

256266
var handler = function (req, res) {
257267
var buffer = proxy.buffer(req);
@@ -263,8 +273,8 @@ TestRunner.prototype.startProxyServerWithTableAndLatency = function (port, laten
263273
};
264274

265275
proxyServer = that.options.https
266-
? https.createServer(that.options.https, handler, that.options)
267-
: http.createServer(handler, that.options);
276+
? https.createServer(that.options.https, handler, that.options)
277+
: http.createServer(handler, that.options);
268278

269279
proxyServer.listen(port, function () {
270280
that.testServers.push(proxyServer);
@@ -278,7 +288,9 @@ TestRunner.prototype.startProxyServerWithTableAndLatency = function (port, laten
278288
// Creates proxy server forwarding to the specified options
279289
//
280290
TestRunner.prototype.startProxyServerWithForwarding = function (port, targetPort, host, options, callback) {
281-
var that = this, proxyServer = httpProxy.createServer(targetPort, host, merge({}, options, this.options));
291+
var that = this,
292+
proxyServer = httpProxy.createServer(targetPort, host, merge({}, options, this.options));
293+
282294
proxyServer.listen(port, function () {
283295
that.testServers.push(proxyServer);
284296
callback(null, proxyServer);
@@ -289,7 +301,11 @@ TestRunner.prototype.startProxyServerWithForwarding = function (port, targetPort
289301
// Creates the 'hellonode' server
290302
//
291303
TestRunner.prototype.startTargetServer = function (port, output, callback) {
292-
var that = this, targetServer, handler = function (req, res) {
304+
var that = this,
305+
targetServer,
306+
handler;
307+
308+
handler = function (req, res) {
293309
res.writeHead(200, { 'Content-Type': 'text/plain' });
294310
res.write(output);
295311
res.end();

0 commit comments

Comments
 (0)