@@ -31,7 +31,7 @@ var vows = require('vows'),
31
31
32
32
require . paths . unshift ( require ( 'path' ) . join ( __dirname , '../lib/' ) ) ;
33
33
34
- var HttpProxy = require ( 'node-http-proxy' ) . HttpProxy ;
34
+ var httpProxy = require ( 'node-http-proxy' ) ;
35
35
var testServers = { } ;
36
36
37
37
//
@@ -77,7 +77,7 @@ var startTargetServer = function (port) {
77
77
//
78
78
var startTest = function ( proxy , port ) {
79
79
testServers . noLatency = [ ] ;
80
- testServers . noLatency . push ( startProxyServer ( '127.0.0.1 ' , port , proxy ) ) ;
80
+ testServers . noLatency . push ( startProxyServer ( 'localhost ' , port , proxy ) ) ;
81
81
testServers . noLatency . push ( startTargetServer ( port ) ) ;
82
82
} ;
83
83
@@ -86,44 +86,48 @@ var startTest = function (proxy, port) {
86
86
//
87
87
var startTestWithLatency = function ( proxy , port ) {
88
88
testServers . latency = [ ] ;
89
- testServers . latency . push ( startLatentProxyServer ( '127.0.0.1 ' , port , proxy , 2000 ) ) ;
89
+ testServers . latency . push ( startLatentProxyServer ( 'localhost ' , port , proxy , 2000 ) ) ;
90
90
testServers . latency . push ( startTargetServer ( port ) ) ;
91
91
} ;
92
92
93
- vows . describe ( 'node-proxy' ) . addBatch ( {
94
- "When an incoming request is proxied to the helloNode server" : {
95
- "with no latency" : {
96
- topic : function ( ) {
97
- var proxy = new ( HttpProxy ) ;
98
- startTest ( proxy , 8082 ) ;
99
- proxy . emitter . addListener ( 'end' , this . callback ) ;
93
+ vows . describe ( 'node-http-proxy' ) . addBatch ( {
94
+ "A node-http-proxy" : {
95
+ "when instantiated directly" : {
96
+ "and an incoming request is proxied to the helloNode server" : {
97
+ "with no latency" : {
98
+ topic : function ( ) {
99
+ var proxy = new ( httpProxy . HttpProxy ) ;
100
+ startTest ( proxy , 8082 ) ;
101
+ proxy . emitter . addListener ( 'end' , this . callback ) ;
100
102
101
- var client = http . createClient ( 8080 , '127.0.0.1 ' ) ;
102
- var request = client . request ( 'GET' , '/' ) ;
103
- request . end ( ) ;
104
- } ,
105
- "it should received 'hello world'" : function ( err , body ) {
106
- assert . equal ( body , 'hello world' ) ;
107
- testServers . noLatency . forEach ( function ( server ) {
108
- server . close ( ) ;
109
- } )
110
- }
111
- } ,
112
- "with latency" : {
113
- topic : function ( ) {
114
- var proxy = new ( HttpProxy ) ;
115
- startTestWithLatency ( proxy , 8083 ) ;
116
- proxy . emitter . addListener ( 'end' , this . callback ) ;
103
+ var client = http . createClient ( 8080 , 'localhost ' ) ;
104
+ var request = client . request ( 'GET' , '/' ) ;
105
+ request . end ( ) ;
106
+ } ,
107
+ "it should received 'hello world'" : function ( err , body ) {
108
+ assert . equal ( body , 'hello world' ) ;
109
+ testServers . noLatency . forEach ( function ( server ) {
110
+ server . close ( ) ;
111
+ } )
112
+ }
113
+ } ,
114
+ "with latency" : {
115
+ topic : function ( ) {
116
+ var proxy = new ( httpProxy . HttpProxy ) ;
117
+ startTestWithLatency ( proxy , 8083 ) ;
118
+ proxy . emitter . addListener ( 'end' , this . callback ) ;
117
119
118
- var client = http . createClient ( 8081 , '127.0.0.1' ) ;
119
- var request = client . request ( 'GET' , '/' ) ;
120
- request . end ( ) ;
121
- } ,
122
- "it should receive 'hello world'" : function ( err , body ) {
123
- assert . equal ( body , 'hello world' ) ;
124
- testServers . latency . forEach ( function ( server ) {
125
- server . close ( ) ;
126
- } )
120
+ var client = http . createClient ( 8081 , 'localhost' ) ;
121
+ var request = client . request ( 'GET' , '/' ) ;
122
+ request . end ( ) ;
123
+ } ,
124
+ "it should receive 'hello world'" : function ( err , body ) {
125
+ assert . equal ( body , 'hello world' ) ;
126
+ testServers . latency . forEach ( function ( server ) {
127
+ server . close ( ) ;
128
+ } )
129
+ }
130
+ }
127
131
}
128
132
}
129
133
}
0 commit comments