@@ -35,7 +35,8 @@ describe('server', function () {
3535 listen ( function ( port ) {
3636 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
3737 . query ( { transport : 'tobi' } ) // no tobi transport - outrageous
38- . end ( function ( res ) {
38+ . end ( function ( err , res ) {
39+ expect ( err ) . to . be . an ( Error ) ;
3940 expect ( res . status ) . to . be ( 400 ) ;
4041 expect ( res . body . code ) . to . be ( 0 ) ;
4142 expect ( res . body . message ) . to . be ( 'Transport unknown' ) ;
@@ -51,7 +52,8 @@ describe('server', function () {
5152 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
5253 . set ( 'Origin' , 'http://engine.io' )
5354 . query ( { transport : 'constructor' } )
54- . end ( function ( res ) {
55+ . end ( function ( err , res ) {
56+ expect ( err ) . to . be . an ( Error ) ;
5557 expect ( res . status ) . to . be ( 400 ) ;
5658 expect ( res . body . code ) . to . be ( 0 ) ;
5759 expect ( res . body . message ) . to . be ( 'Transport unknown' ) ;
@@ -67,7 +69,8 @@ describe('server', function () {
6769 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
6870 . set ( 'Origin' , 'http://engine.io' )
6971 . query ( { transport : 'polling' , sid : 'test' } )
70- . end ( function ( res ) {
72+ . end ( function ( err , res ) {
73+ expect ( err ) . to . be . an ( Error ) ;
7174 expect ( res . status ) . to . be ( 400 ) ;
7275 expect ( res . body . code ) . to . be ( 1 ) ;
7376 expect ( res . body . message ) . to . be ( 'Session ID unknown' ) ;
@@ -83,7 +86,8 @@ describe('server', function () {
8386 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
8487 . set ( 'Origin' , 'http://engine.io' )
8588 . query ( { transport : 'polling' } )
86- . end ( function ( res ) {
89+ . end ( function ( err , res ) {
90+ expect ( err ) . to . be . an ( Error ) ;
8791 expect ( res . status ) . to . be ( 403 ) ;
8892 expect ( res . body . code ) . to . be ( 4 ) ;
8993 expect ( res . body . message ) . to . be ( 'Thou shall not pass' ) ;
@@ -109,7 +113,8 @@ describe('server', function () {
109113 listen ( function ( port ) {
110114 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
111115 . query ( { transport : 'polling' , b64 : 1 } )
112- . end ( function ( res ) {
116+ . end ( function ( err , res ) {
117+ expect ( err ) . to . be ( null ) ;
113118 // hack-obtain sid
114119 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
115120 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
@@ -122,7 +127,8 @@ describe('server', function () {
122127 listen ( { cookie : 'woot' } , function ( port ) {
123128 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
124129 . query ( { transport : 'polling' , b64 : 1 } )
125- . end ( function ( res ) {
130+ . end ( function ( err , res ) {
131+ expect ( err ) . to . be ( null ) ;
126132 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
127133 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'woot=' + sid + '; Path=/; HttpOnly' ) ;
128134 done ( ) ;
@@ -134,7 +140,8 @@ describe('server', function () {
134140 listen ( { cookiePath : '/custom' } , function ( port ) {
135141 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
136142 . query ( { transport : 'polling' , b64 : 1 } )
137- . end ( function ( res ) {
143+ . end ( function ( err , res ) {
144+ expect ( err ) . to . be ( null ) ;
138145 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
139146 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/custom; HttpOnly' ) ;
140147 done ( ) ;
@@ -146,7 +153,8 @@ describe('server', function () {
146153 listen ( { cookiePath : false } , function ( port ) {
147154 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
148155 . query ( { transport : 'polling' , b64 : 1 } )
149- . end ( function ( res ) {
156+ . end ( function ( err , res ) {
157+ expect ( err ) . to . be ( null ) ;
150158 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
151159 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid ) ;
152160 done ( ) ;
@@ -158,7 +166,8 @@ describe('server', function () {
158166 listen ( { cookieHttpOnly : true } , function ( port ) {
159167 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
160168 . query ( { transport : 'polling' , b64 : 1 } )
161- . end ( function ( res ) {
169+ . end ( function ( err , res ) {
170+ expect ( err ) . to . be ( null ) ;
162171 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
163172 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
164173 done ( ) ;
@@ -170,7 +179,8 @@ describe('server', function () {
170179 listen ( { cookieHttpOnly : true , cookiePath : false } , function ( port ) {
171180 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
172181 . query ( { transport : 'polling' , b64 : 1 } )
173- . end ( function ( res ) {
182+ . end ( function ( err , res ) {
183+ expect ( err ) . to . be ( null ) ;
174184 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
175185 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid ) ;
176186 done ( ) ;
@@ -182,7 +192,8 @@ describe('server', function () {
182192 listen ( { cookieHttpOnly : false } , function ( port ) {
183193 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
184194 . query ( { transport : 'polling' , b64 : 1 } )
185- . end ( function ( res ) {
195+ . end ( function ( err , res ) {
196+ expect ( err ) . to . be ( null ) ;
186197 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
187198 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/' ) ;
188199 done ( ) ;
@@ -194,7 +205,8 @@ describe('server', function () {
194205 listen ( { cookieHttpOnly : 'no' } , function ( port ) {
195206 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
196207 . query ( { transport : 'polling' , b64 : 1 } )
197- . end ( function ( res ) {
208+ . end ( function ( err , res ) {
209+ expect ( err ) . to . be ( null ) ;
198210 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
199211 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
200212 done ( ) ;
@@ -206,7 +218,8 @@ describe('server', function () {
206218 listen ( { cookie : false } , function ( port ) {
207219 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
208220 . query ( { transport : 'polling' } )
209- . end ( function ( res ) {
221+ . end ( function ( err , res ) {
222+ expect ( err ) . to . be ( null ) ;
210223 expect ( res . headers [ 'set-cookie' ] ) . to . be ( undefined ) ;
211224 done ( ) ;
212225 } ) ;
@@ -356,7 +369,7 @@ describe('server', function () {
356369 . set ( { connection : 'close' } )
357370 . query ( { transport : 'websocket' , sid : socket . id } )
358371 . end ( function ( err , res ) {
359- expect ( err ) . to . be ( null ) ;
372+ expect ( err ) . to . be . an ( Error ) ;
360373 expect ( res . status ) . to . be ( 400 ) ;
361374 expect ( res . body . code ) . to . be ( 3 ) ;
362375 socket . send ( 'echo' ) ;
@@ -397,7 +410,8 @@ describe('server', function () {
397410 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
398411 . set ( 'Origin' , 'http://engine.io' )
399412 . query ( { transport : 'websocket' } )
400- . end ( function ( res ) {
413+ . end ( function ( err , res ) {
414+ expect ( err ) . to . be . an ( Error ) ;
401415 expect ( res . status ) . to . be ( 400 ) ;
402416 expect ( res . body . code ) . to . be ( 3 ) ;
403417 expect ( res . body . message ) . to . be ( 'Bad request' ) ;
@@ -2579,7 +2593,8 @@ describe('server', function () {
25792593 request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
25802594 . set ( 'Origin' , 'http://engine.io' )
25812595 . query ( { transport : 'polling' } )
2582- . end ( function ( res ) {
2596+ . end ( function ( err , res ) {
2597+ expect ( err ) . to . be . an ( Error ) ;
25832598 expect ( res . status ) . to . be ( 400 ) ;
25842599 expect ( res . body . code ) . to . be ( 2 ) ;
25852600 expect ( res . body . message ) . to . be ( 'Bad handshake method' ) ;
@@ -2595,7 +2610,8 @@ describe('server', function () {
25952610 request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
25962611 . set ( 'Origin' , 'http://engine.io' )
25972612 . query ( { transport : 'polling' } )
2598- . end ( function ( res ) {
2613+ . end ( function ( err , res ) {
2614+ expect ( err ) . to . be . an ( Error ) ;
25992615 expect ( res . status ) . to . be ( 501 ) ;
26002616 expect ( res . body . code ) . to . be ( undefined ) ;
26012617 done ( ) ;
@@ -2621,7 +2637,8 @@ describe('server', function () {
26212637 request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
26222638 . set ( 'Origin' , 'http://engine.io' )
26232639 . query ( { transport : 'polling' } )
2624- . end ( function ( res ) {
2640+ . end ( function ( err , res ) {
2641+ expect ( err ) . to . be ( null ) ;
26252642 expect ( res . status ) . to . be ( 200 ) ;
26262643 expect ( res . body ) . to . be . empty ( ) ;
26272644 expect ( res . header [ 'access-control-allow-credentials' ] ) . to . be ( 'true' ) ;
0 commit comments