@@ -31,7 +31,7 @@ describe('[node] request', () => {
31
31
describe ( 'with an object' , ( ) => {
32
32
it ( 'should format the url' , ( ) =>
33
33
request . get ( url . parse ( `${ base } /login` ) ) . then ( ( res ) => {
34
- assert ( res . ok ) ;
34
+ assert . ok ( res . ok ) ;
35
35
} ) ) ;
36
36
} ) ;
37
37
@@ -59,12 +59,13 @@ describe('[node] request', () => {
59
59
describe ( 'res.links' , ( ) => {
60
60
it ( 'should default to an empty object' , ( ) =>
61
61
request . get ( `${ base } /login` ) . then ( ( res ) => {
62
- res . links . should . eql ( { } ) ;
62
+ assert . deepEqual ( res . links , { } ) ;
63
63
} ) ) ;
64
64
65
65
it ( 'should parse the Link header field' , ( done ) => {
66
66
request . get ( `${ base } /links` ) . end ( ( error , res ) => {
67
- res . links . next . should . equal (
67
+ assert . equal (
68
+ res . links . next ,
68
69
'https://api.github.com/repos/visionmedia/mocha/issues?page=2'
69
70
) ;
70
71
done ( ) ;
@@ -78,24 +79,24 @@ describe('[node] request', () => {
78
79
. post ( `${ base } /echo` )
79
80
. unset ( 'User-Agent' )
80
81
. end ( ( error , res ) => {
81
- assert . equal ( void 0 , res . header [ 'user-agent' ] ) ;
82
+ assert . equal ( res . header [ 'user-agent' ] , undefined ) ;
82
83
done ( ) ;
83
84
} ) ;
84
85
} ) ;
85
86
} ) ;
86
87
87
88
describe ( 'case-insensitive' , ( ) => {
88
89
it ( 'should set/get header fields case-insensitively' , ( ) => {
89
- const r = request . post ( `${ base } /echo` ) ;
90
- r . set ( 'MiXeD' , 'helloes' ) ;
91
- assert . strictEqual ( r . get ( 'mixed' ) , 'helloes' ) ;
90
+ const req = request . post ( `${ base } /echo` ) ;
91
+ req . set ( 'MiXeD' , 'helloes' ) ;
92
+ assert . strictEqual ( req . get ( 'mixed' ) , 'helloes' ) ;
92
93
} ) ;
93
94
94
95
it ( 'should unset header fields case-insensitively' , ( ) => {
95
- const r = request . post ( `${ base } /echo` ) ;
96
- r . set ( 'MiXeD' , 'helloes' ) ;
97
- r . unset ( 'MIXED' ) ;
98
- assert . strictEqual ( r . get ( 'mixed' ) , undefined ) ;
96
+ const req = request . post ( `${ base } /echo` ) ;
97
+ req . set ( 'MiXeD' , 'helloes' ) ;
98
+ req . unset ( 'MIXED' ) ;
99
+ assert . strictEqual ( req . get ( 'mixed' ) , undefined ) ;
99
100
} ) ;
100
101
} ) ;
101
102
@@ -106,7 +107,7 @@ describe('[node] request', () => {
106
107
assert . equal ( 'boolean' , typeof request_ . write ( '{"name"' ) ) ;
107
108
assert . equal ( 'boolean' , typeof request_ . write ( ':"tobi"}' ) ) ;
108
109
request_ . end ( ( error , res ) => {
109
- res . text . should . equal ( '{"name":"tobi"}' ) ;
110
+ assert . equal ( res . text , '{"name":"tobi"}' ) ;
110
111
done ( ) ;
111
112
} ) ;
112
113
} ) ;
@@ -116,19 +117,21 @@ describe('[node] request', () => {
116
117
it ( 'should pipe the response to the given stream' , ( done ) => {
117
118
const stream = new EventEmitter ( ) ;
118
119
119
- stream . buf = '' ;
120
+ let buf = '' ;
120
121
stream . writable = true ;
121
122
122
123
stream . write = function ( chunk ) {
123
- this . buf += chunk ;
124
+ buf += chunk ;
124
125
} ;
125
126
126
127
stream . end = function ( ) {
127
- this . buf . should . equal ( '{"name":"tobi"}' ) ;
128
+ assert . equal ( buf , '{"name":"tobi"}' ) ;
128
129
done ( ) ;
129
130
} ;
130
131
131
- request . post ( `${ base } /echo` ) . send ( '{"name":"tobi"}' ) . pipe ( stream ) ;
132
+ request . post ( `${ base } /echo` )
133
+ . send ( '{"name":"tobi"}' )
134
+ . pipe ( stream ) ;
132
135
} ) ;
133
136
} ) ;
134
137
@@ -140,7 +143,7 @@ describe('[node] request', () => {
140
143
. end ( ( error , res ) => {
141
144
assert . ifError ( error ) ;
142
145
assert . equal ( 'custom stuff' , res . text ) ;
143
- assert ( res . buffered ) ;
146
+ assert . ok ( res . buffered ) ;
144
147
done ( ) ;
145
148
} ) ;
146
149
} ) ;
@@ -158,7 +161,7 @@ describe('[node] request', () => {
158
161
assert . ifError ( error ) ;
159
162
assert . equal ( res . type , type ) ;
160
163
assert . equal ( send , res . text ) ;
161
- assert ( res . buffered ) ;
164
+ assert . ok ( res . buffered ) ;
162
165
done ( ) ;
163
166
} ) ;
164
167
} ) ;
@@ -174,18 +177,19 @@ describe('[node] request', () => {
174
177
. end ( ( error , res ) => {
175
178
assert . ifError ( error ) ;
176
179
assert . equal ( null , res . text ) ;
177
- res . body . should . eql ( { } ) ;
178
- let buf = '' ;
180
+ assert . deepEqual ( res . body , { } ) ;
181
+ let str = '' ;
179
182
res . setEncoding ( 'utf8' ) ;
180
183
res . on ( 'data' , ( chunk ) => {
181
- buf += chunk ;
184
+ str += chunk ;
182
185
} ) ;
183
186
res . on ( 'end' , ( ) => {
184
- buf . should . equal ( 'hello this is dog' ) ;
187
+ assert . equal ( str , 'hello this is dog' ) ;
185
188
done ( ) ;
186
189
} ) ;
187
190
} ) ;
188
191
} ) ;
192
+
189
193
it ( "should take precedence over request.buffer['someMimeType'] = true" , ( done ) => {
190
194
const type = 'application/foobar' ;
191
195
const send = 'hello this is a dog' ;
@@ -200,15 +204,15 @@ describe('[node] request', () => {
200
204
assert . ifError ( error ) ;
201
205
assert . equal ( null , res . text ) ;
202
206
assert . equal ( res . type , type ) ;
203
- assert ( ! res . buffered ) ;
204
- res . body . should . eql ( { } ) ;
205
- let buf = '' ;
207
+ assert . equal ( res . buffered , false ) ;
208
+ assert . deepEqual ( res . body , { } ) ;
209
+ let str = '' ;
206
210
res . setEncoding ( 'utf8' ) ;
207
211
res . on ( 'data' , ( chunk ) => {
208
- buf += chunk ;
212
+ str += chunk ;
209
213
} ) ;
210
214
res . on ( 'end' , ( ) => {
211
- buf . should . equal ( send ) ;
215
+ assert . equal ( str , send ) ;
212
216
done ( ) ;
213
217
} ) ;
214
218
} ) ;
@@ -229,8 +233,8 @@ describe('[node] request', () => {
229
233
230
234
describe ( '.agent()' , ( ) => {
231
235
it ( 'should return the defaut agent' , ( done ) => {
232
- const request_ = request . post ( `${ base } /echo` ) ;
233
- request_ . agent ( ) . should . equal ( false ) ;
236
+ const agent = request . post ( `${ base } /echo` ) . agent ( ) ;
237
+ assert . equal ( agent , false ) ;
234
238
done ( ) ;
235
239
} ) ;
236
240
} ) ;
@@ -239,7 +243,7 @@ describe('[node] request', () => {
239
243
it ( 'should set an agent to undefined and ensure it is chainable' , ( done ) => {
240
244
const request_ = request . get ( `${ base } /echo` ) ;
241
245
const returnValue = request_ . agent ( undefined ) ;
242
- returnValue . should . equal ( request_ ) ;
246
+ assert . equal ( returnValue , request_ ) ;
243
247
assert . strictEqual ( request_ . agent ( ) , undefined ) ;
244
248
done ( ) ;
245
249
} ) ;
@@ -251,8 +255,8 @@ describe('[node] request', () => {
251
255
const request_ = request . get ( `${ base } /echo` ) ;
252
256
const agent = new http . Agent ( ) ;
253
257
const returnValue = request_ . agent ( agent ) ;
254
- returnValue . should . equal ( request_ ) ;
255
- request_ . agent ( ) . should . equal ( agent ) ;
258
+ assert . equal ( returnValue , request_ ) ;
259
+ assert . equal ( request_ . agent ( ) , agent ) ;
256
260
done ( ) ;
257
261
} ) ;
258
262
} ) ;
@@ -264,9 +268,9 @@ describe('[node] request', () => {
264
268
. type ( 'application/x-dog' )
265
269
. send ( 'hello this is dog' )
266
270
. then ( ( res ) => {
267
- assert . equal ( null , res . text ) ;
271
+ assert . equal ( res . text , null ) ;
268
272
assert . equal ( res . body . toString ( ) , 'hello this is dog' ) ;
269
- res . buffered . should . be . true ;
273
+ assert . equal ( res . buffered , true ) ;
270
274
} ) ;
271
275
} ) ;
272
276
} ) ;
@@ -283,7 +287,7 @@ describe('[node] request', () => {
283
287
. buffer ( false )
284
288
. end ( ( error , res ) => {
285
289
assert . ifError ( error ) ;
286
- assert ( ! res . buffered ) ;
290
+ assert . equal ( res . buffered , false ) ;
287
291
assert . equal ( res . header [ 'content-length' ] , Buffer . byteLength ( img ) ) ;
288
292
done ( ) ;
289
293
} ) ;
@@ -313,7 +317,7 @@ describe('[node] request', () => {
313
317
. send ( 'wahoo' )
314
318
. end ( ( error , res ) => {
315
319
try {
316
- assert . equal ( 'wahoo' , res . text ) ;
320
+ assert . equal ( res . text , 'wahoo' ) ;
317
321
next ( ) ;
318
322
} catch ( err ) {
319
323
next ( err ) ;
0 commit comments