@@ -9,7 +9,8 @@ var fake_res = {
99 status : function ( ) { } ,
1010 json : function ( ) { } ,
1111 send : function ( ) { } ,
12- setHeader : function ( ) { }
12+ setHeader : function ( ) { } ,
13+ writeHead : function ( ) { }
1314} ;
1415
1516var fake_req = {
@@ -191,6 +192,7 @@ describe("responder.js", function () {
191192 context ( "when args.contentType not passed in" , function ( ) {
192193 it ( "responds with Content-Type header set to application/octet-stream" , function ( done ) {
193194 sinon . spy ( fake_res , 'setHeader' ) ;
195+ sinon . spy ( fake_res , 'writeHead' ) ;
194196 sinon . stub ( args . stream , 'pipe' ) . callsFake ( function ( ) { } ) ;
195197
196198 delete args . contentType ;
@@ -199,6 +201,7 @@ describe("responder.js", function () {
199201 assert . ok ( fake_res . setHeader . calledWith ( 'Content-Type' , 'application/octet-stream' ) ) ;
200202
201203 fake_res . setHeader . restore ( ) ;
204+ fake_res . writeHead . restore ( ) ;
202205 args . stream . pipe . restore ( ) ;
203206 done ( ) ;
204207 } ) ;
@@ -207,6 +210,7 @@ describe("responder.js", function () {
207210 context ( "when args.contentLength not passed in" , function ( ) {
208211 it ( "responds without Content-Length header set" , function ( done ) {
209212 sinon . spy ( fake_res , 'setHeader' ) ;
213+ sinon . spy ( fake_res , 'writeHead' ) ;
210214 sinon . stub ( args . stream , 'pipe' ) . callsFake ( function ( ) { } ) ;
211215
212216 delete args . contentLength ;
@@ -215,26 +219,28 @@ describe("responder.js", function () {
215219 assert . ok ( ! fake_res . setHeader . calledWith ( 'Content-Length' ) ) ;
216220
217221 fake_res . setHeader . restore ( ) ;
222+ fake_res . writeHead . restore ( ) ;
218223 args . stream . pipe . restore ( ) ;
219224 done ( ) ;
220225 } ) ;
221226 } ) ;
222227
223228 context ( "when args passed in correctly" , function ( ) {
224- it ( "responds without 200 status and content" , function ( done ) {
229+ it ( "responds with 200 status and content" , function ( done ) {
225230 sinon . spy ( fake_res , 'setHeader' ) ;
226- sinon . spy ( fake_res , 'status ' ) ;
231+ sinon . spy ( fake_res , 'writeHead ' ) ;
227232 sinon . stub ( args . stream , 'pipe' ) . callsFake ( function ( ) { } ) ;
228233
229234 responder . download ( fake_res , args , fake_next ) ;
230235
231236 assert . ok ( fake_res . setHeader . calledWith ( 'Content-Type' , 'application/javascript' ) ) ;
232237 assert . ok ( fake_res . setHeader . calledWith ( 'Content-Length' , 2000 ) ) ;
233238 assert . ok ( fake_res . setHeader . calledWith ( 'Content-Disposition' , 'attachment; filename=foo.js' ) ) ;
234- assert . ok ( fake_res . status . calledWith ( 200 ) ) ;
239+ assert . ok ( fake_res . writeHead . calledWith ( 200 ) ) ;
235240 assert . ok ( args . stream . pipe . calledWith ( fake_res ) ) ;
236241
237242 fake_res . setHeader . restore ( ) ;
243+ fake_res . writeHead . restore ( ) ;
238244 args . stream . pipe . restore ( ) ;
239245 done ( ) ;
240246 } ) ;
0 commit comments