@@ -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 = {
@@ -46,7 +47,7 @@ describe("responder.js", function () {
4647
4748 context ( "when no data passed in" , function ( ) {
4849 it ( "calls responder.error()" , function ( done ) {
49- sinon . stub ( responder , 'error' , function ( res , err , next ) {
50+ sinon . stub ( responder , 'error' ) . callsFake ( function ( res , err , next ) {
5051 next ( ) ;
5152 } ) ;
5253
@@ -82,7 +83,7 @@ describe("responder.js", function () {
8283
8384 context ( "when no args passed in" , function ( ) {
8485 it ( "responds with an InternalError" , function ( done ) {
85- sinon . stub ( responder , 'error' , function ( res , err , next ) {
86+ sinon . stub ( responder , 'error' ) . callsFake ( function ( res , err , next ) {
8687 next ( ) ;
8788 } ) ;
8889
@@ -97,7 +98,7 @@ describe("responder.js", function () {
9798
9899 context ( "when args.url not passed in" , function ( ) {
99100 it ( "responds with an InternalError" , function ( done ) {
100- sinon . stub ( responder , 'error' , function ( res , err , next ) {
101+ sinon . stub ( responder , 'error' ) . callsFake ( function ( res , err , next ) {
101102 next ( ) ;
102103 } ) ;
103104
@@ -143,7 +144,7 @@ describe("responder.js", function () {
143144
144145 context ( "when no args passed in" , function ( ) {
145146 it ( "responds with an InternalError" , function ( done ) {
146- sinon . stub ( responder , 'error' , function ( res , err , next ) {
147+ sinon . stub ( responder , 'error' ) . callsFake ( function ( res , err , next ) {
147148 next ( ) ;
148149 } ) ;
149150
@@ -158,7 +159,7 @@ describe("responder.js", function () {
158159
159160 context ( "when args.filename not passed in" , function ( ) {
160161 it ( "responds with an InternalError" , function ( done ) {
161- sinon . stub ( responder , 'error' , function ( res , err , next ) {
162+ sinon . stub ( responder , 'error' ) . callsFake ( function ( res , err , next ) {
162163 next ( ) ;
163164 } ) ;
164165
@@ -174,7 +175,7 @@ describe("responder.js", function () {
174175
175176 context ( "when args.stream not passed in" , function ( ) {
176177 it ( "responds with an InternalError" , function ( done ) {
177- sinon . stub ( responder , 'error' , function ( res , err , next ) {
178+ sinon . stub ( responder , 'error' ) . callsFake ( function ( res , err , next ) {
178179 next ( ) ;
179180 } ) ;
180181
@@ -191,7 +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' ) ;
194- sinon . stub ( args . stream , 'pipe' , function ( ) { } ) ;
195+ sinon . stub ( args . stream , 'pipe' ) . callsFake ( function ( ) { } ) ;
195196
196197 delete args . contentType ;
197198 responder . download ( fake_res , args , fake_next ) ;
@@ -207,7 +208,7 @@ describe("responder.js", function () {
207208 context ( "when args.contentLength not passed in" , function ( ) {
208209 it ( "responds without Content-Length header set" , function ( done ) {
209210 sinon . spy ( fake_res , 'setHeader' ) ;
210- sinon . stub ( args . stream , 'pipe' , function ( ) { } ) ;
211+ sinon . stub ( args . stream , 'pipe' ) . callsFake ( function ( ) { } ) ;
211212
212213 delete args . contentLength ;
213214 responder . download ( fake_res , args , fake_next ) ;
@@ -221,20 +222,21 @@ describe("responder.js", function () {
221222 } ) ;
222223
223224 context ( "when args passed in correctly" , function ( ) {
224- it ( "responds without 200 status and content" , function ( done ) {
225+ it ( "responds with 200 status and content" , function ( done ) {
225226 sinon . spy ( fake_res , 'setHeader' ) ;
226- sinon . spy ( fake_res , 'status ' ) ;
227- sinon . stub ( args . stream , 'pipe' , function ( ) { } ) ;
227+ sinon . spy ( fake_res , 'writeHead ' ) ;
228+ sinon . stub ( args . stream , 'pipe' ) . callsFake ( function ( ) { } ) ;
228229
229230 responder . download ( fake_res , args , fake_next ) ;
230231
231232 assert . ok ( fake_res . setHeader . calledWith ( 'Content-Type' , 'application/javascript' ) ) ;
232233 assert . ok ( fake_res . setHeader . calledWith ( 'Content-Length' , 2000 ) ) ;
233234 assert . ok ( fake_res . setHeader . calledWith ( 'Content-Disposition' , 'attachment; filename=foo.js' ) ) ;
234- assert . ok ( fake_res . status . calledWith ( 200 ) ) ;
235+ assert . ok ( fake_res . writeHead . calledWith ( 200 ) ) ;
235236 assert . ok ( args . stream . pipe . calledWith ( fake_res ) ) ;
236237
237238 fake_res . setHeader . restore ( ) ;
239+ fake_res . writeHead . restore ( ) ;
238240 args . stream . pipe . restore ( ) ;
239241 done ( ) ;
240242 } ) ;
0 commit comments