@@ -36,7 +36,8 @@ describe('server', function () {
3636 listen ( function ( port ) {
3737 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
3838 . query ( { transport : 'tobi' } ) // no tobi transport - outrageous
39- . end ( function ( res ) {
39+ . end ( function ( err , res ) {
40+ expect ( err ) . to . be . an ( Error ) ;
4041 expect ( res . status ) . to . be ( 400 ) ;
4142 expect ( res . body . code ) . to . be ( 0 ) ;
4243 expect ( res . body . message ) . to . be ( 'Transport unknown' ) ;
@@ -52,7 +53,8 @@ describe('server', function () {
5253 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
5354 . set ( 'Origin' , 'http://engine.io' )
5455 . query ( { transport : 'constructor' } )
55- . end ( function ( res ) {
56+ . end ( function ( err , res ) {
57+ expect ( err ) . to . be . an ( Error ) ;
5658 expect ( res . status ) . to . be ( 400 ) ;
5759 expect ( res . body . code ) . to . be ( 0 ) ;
5860 expect ( res . body . message ) . to . be ( 'Transport unknown' ) ;
@@ -68,7 +70,8 @@ describe('server', function () {
6870 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
6971 . set ( 'Origin' , 'http://engine.io' )
7072 . query ( { transport : 'polling' , sid : 'test' } )
71- . end ( function ( res ) {
73+ . end ( function ( err , res ) {
74+ expect ( err ) . to . be . an ( Error ) ;
7275 expect ( res . status ) . to . be ( 400 ) ;
7376 expect ( res . body . code ) . to . be ( 1 ) ;
7477 expect ( res . body . message ) . to . be ( 'Session ID unknown' ) ;
@@ -84,7 +87,8 @@ describe('server', function () {
8487 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
8588 . set ( 'Origin' , 'http://engine.io' )
8689 . query ( { transport : 'polling' } )
87- . end ( function ( res ) {
90+ . end ( function ( err , res ) {
91+ expect ( err ) . to . be . an ( Error ) ;
8892 expect ( res . status ) . to . be ( 403 ) ;
8993 expect ( res . body . code ) . to . be ( 4 ) ;
9094 expect ( res . body . message ) . to . be ( 'Thou shall not pass' ) ;
@@ -110,7 +114,8 @@ describe('server', function () {
110114 listen ( function ( port ) {
111115 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
112116 . query ( { transport : 'polling' , b64 : 1 } )
113- . end ( function ( res ) {
117+ . end ( function ( err , res ) {
118+ expect ( err ) . to . be ( null ) ;
114119 // hack-obtain sid
115120 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
116121 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
@@ -123,7 +128,8 @@ describe('server', function () {
123128 listen ( { cookie : 'woot' } , function ( port ) {
124129 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
125130 . query ( { transport : 'polling' , b64 : 1 } )
126- . end ( function ( res ) {
131+ . end ( function ( err , res ) {
132+ expect ( err ) . to . be ( null ) ;
127133 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
128134 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'woot=' + sid + '; Path=/; HttpOnly' ) ;
129135 done ( ) ;
@@ -135,7 +141,8 @@ describe('server', function () {
135141 listen ( { cookiePath : '/custom' } , function ( port ) {
136142 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
137143 . query ( { transport : 'polling' , b64 : 1 } )
138- . end ( function ( res ) {
144+ . end ( function ( err , res ) {
145+ expect ( err ) . to . be ( null ) ;
139146 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
140147 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/custom; HttpOnly' ) ;
141148 done ( ) ;
@@ -147,7 +154,8 @@ describe('server', function () {
147154 listen ( { cookiePath : false } , function ( port ) {
148155 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
149156 . query ( { transport : 'polling' , b64 : 1 } )
150- . end ( function ( res ) {
157+ . end ( function ( err , res ) {
158+ expect ( err ) . to . be ( null ) ;
151159 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
152160 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid ) ;
153161 done ( ) ;
@@ -159,7 +167,8 @@ describe('server', function () {
159167 listen ( { cookieHttpOnly : true } , function ( port ) {
160168 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
161169 . query ( { transport : 'polling' , b64 : 1 } )
162- . end ( function ( res ) {
170+ . end ( function ( err , res ) {
171+ expect ( err ) . to . be ( null ) ;
163172 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
164173 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
165174 done ( ) ;
@@ -171,7 +180,8 @@ describe('server', function () {
171180 listen ( { cookieHttpOnly : true , cookiePath : false } , function ( port ) {
172181 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
173182 . query ( { transport : 'polling' , b64 : 1 } )
174- . end ( function ( res ) {
183+ . end ( function ( err , res ) {
184+ expect ( err ) . to . be ( null ) ;
175185 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
176186 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid ) ;
177187 done ( ) ;
@@ -183,7 +193,8 @@ describe('server', function () {
183193 listen ( { cookieHttpOnly : false } , function ( port ) {
184194 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
185195 . query ( { transport : 'polling' , b64 : 1 } )
186- . end ( function ( res ) {
196+ . end ( function ( err , res ) {
197+ expect ( err ) . to . be ( null ) ;
187198 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
188199 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/' ) ;
189200 done ( ) ;
@@ -195,7 +206,8 @@ describe('server', function () {
195206 listen ( { cookieHttpOnly : 'no' } , function ( port ) {
196207 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
197208 . query ( { transport : 'polling' , b64 : 1 } )
198- . end ( function ( res ) {
209+ . end ( function ( err , res ) {
210+ expect ( err ) . to . be ( null ) ;
199211 var sid = res . text . match ( / " s i d " : " ( [ ^ " ] + ) " / ) [ 1 ] ;
200212 expect ( res . headers [ 'set-cookie' ] [ 0 ] ) . to . be ( 'io=' + sid + '; Path=/; HttpOnly' ) ;
201213 done ( ) ;
@@ -207,7 +219,8 @@ describe('server', function () {
207219 listen ( { cookie : false } , function ( port ) {
208220 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
209221 . query ( { transport : 'polling' } )
210- . end ( function ( res ) {
222+ . end ( function ( err , res ) {
223+ expect ( err ) . to . be ( null ) ;
211224 expect ( res . headers [ 'set-cookie' ] ) . to . be ( undefined ) ;
212225 done ( ) ;
213226 } ) ;
@@ -369,7 +382,7 @@ describe('server', function () {
369382 . set ( { connection : 'close' } )
370383 . query ( { transport : 'websocket' , sid : socket . id } )
371384 . end ( function ( err , res ) {
372- expect ( err ) . to . be ( null ) ;
385+ expect ( err ) . to . be . an ( Error ) ;
373386 expect ( res . status ) . to . be ( 400 ) ;
374387 expect ( res . body . code ) . to . be ( 3 ) ;
375388 socket . send ( 'echo' ) ;
@@ -410,7 +423,8 @@ describe('server', function () {
410423 request . get ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
411424 . set ( 'Origin' , 'http://engine.io' )
412425 . query ( { transport : 'websocket' } )
413- . end ( function ( res ) {
426+ . end ( function ( err , res ) {
427+ expect ( err ) . to . be . an ( Error ) ;
414428 expect ( res . status ) . to . be ( 400 ) ;
415429 expect ( res . body . code ) . to . be ( 3 ) ;
416430 expect ( res . body . message ) . to . be ( 'Bad request' ) ;
@@ -2592,7 +2606,8 @@ describe('server', function () {
25922606 request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
25932607 . set ( 'Origin' , 'http://engine.io' )
25942608 . query ( { transport : 'polling' } )
2595- . end ( function ( res ) {
2609+ . end ( function ( err , res ) {
2610+ expect ( err ) . to . be . an ( Error ) ;
25962611 expect ( res . status ) . to . be ( 400 ) ;
25972612 expect ( res . body . code ) . to . be ( 2 ) ;
25982613 expect ( res . body . message ) . to . be ( 'Bad handshake method' ) ;
@@ -2608,7 +2623,8 @@ describe('server', function () {
26082623 request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
26092624 . set ( 'Origin' , 'http://engine.io' )
26102625 . query ( { transport : 'polling' } )
2611- . end ( function ( res ) {
2626+ . end ( function ( err , res ) {
2627+ expect ( err ) . to . be . an ( Error ) ;
26122628 expect ( res . status ) . to . be ( 501 ) ;
26132629 expect ( res . body . code ) . to . be ( undefined ) ;
26142630 done ( ) ;
@@ -2634,7 +2650,8 @@ describe('server', function () {
26342650 request . options ( 'http://localhost:%d/engine.io/default/' . s ( port ) )
26352651 . set ( 'Origin' , 'http://engine.io' )
26362652 . query ( { transport : 'polling' } )
2637- . end ( function ( res ) {
2653+ . end ( function ( err , res ) {
2654+ expect ( err ) . to . be ( null ) ;
26382655 expect ( res . status ) . to . be ( 200 ) ;
26392656 expect ( res . body ) . to . be . empty ( ) ;
26402657 expect ( res . header [ 'access-control-allow-credentials' ] ) . to . be ( 'true' ) ;
0 commit comments