14
14
/*!
15
15
* Module dependencies.
16
16
*/
17
- import net from " net" ;
18
- import url from " url" ;
19
- import Cookie from " cookiejar" ;
20
- import charset from " charset" ;
21
- import qs from "qs" ;
22
- import * as _request from " ./request.js" ;
17
+ import net from ' net' ;
18
+ import url from ' url' ;
19
+ import Cookie from ' cookiejar' ;
20
+ import charset from ' charset' ;
21
+ import qs from 'qs' ;
22
+ import * as _request from ' ./request.js' ;
23
23
24
24
/**
25
25
*
@@ -48,9 +48,9 @@ export default function (chai, _) {
48
48
*/
49
49
50
50
const contentTypes = {
51
- json : " application/json" ,
52
- text : " text/plain" ,
53
- html : " text/html" ,
51
+ json : ' application/json' ,
52
+ text : ' text/plain' ,
53
+ html : ' text/html'
54
54
} ;
55
55
56
56
/*!
@@ -81,27 +81,27 @@ export default function (chai, _) {
81
81
* @api public
82
82
*/
83
83
84
- Assertion . addMethod ( " status" , function ( code ) {
84
+ Assertion . addMethod ( ' status' , function ( code ) {
85
85
const hasStatus = Boolean (
86
- " status" in this . _obj || " statusCode" in this . _obj ,
86
+ ' status' in this . _obj || ' statusCode' in this . _obj
87
87
) ;
88
88
new Assertion ( hasStatus ) . assert (
89
89
hasStatus ,
90
90
"expected #{act} to have keys 'status', or 'statusCode'" ,
91
91
null , // never negated
92
92
hasStatus , // expected
93
93
this . _obj , // actual
94
- false , // no diff
94
+ false // no diff
95
95
) ;
96
96
97
97
const status = this . _obj . status || this . _obj . statusCode ;
98
98
99
99
this . assert (
100
100
status == code ,
101
- " expected #{this} to have status code #{exp} but got #{act}" ,
102
- " expected #{this} to not have status code #{act}" ,
101
+ ' expected #{this} to have status code #{exp} but got #{act}' ,
102
+ ' expected #{this} to not have status code #{act}' ,
103
103
code ,
104
- status ,
104
+ status
105
105
) ;
106
106
} ) ;
107
107
@@ -130,14 +130,14 @@ export default function (chai, _) {
130
130
* @api public
131
131
*/
132
132
133
- Assertion . addMethod ( " header" , function ( key , value ) {
133
+ Assertion . addMethod ( ' header' , function ( key , value ) {
134
134
const header = getHeader ( this . _obj , key ) ;
135
135
136
136
if ( arguments . length < 2 ) {
137
137
this . assert (
138
- " undefined" !== typeof header || null === header ,
138
+ ' undefined' !== typeof header || null === header ,
139
139
"expected header '" + key + "' to exist" ,
140
- "expected header '" + key + "' to not exist" ,
140
+ "expected header '" + key + "' to not exist"
141
141
) ;
142
142
} else if ( arguments [ 1 ] instanceof RegExp ) {
143
143
this . assert (
@@ -146,16 +146,16 @@ export default function (chai, _) {
146
146
key +
147
147
"' to match " +
148
148
value +
149
- " but got " +
149
+ ' but got ' +
150
150
i ( header ) ,
151
151
"expected header '" +
152
152
key +
153
153
"' not to match " +
154
154
value +
155
- " but got " +
155
+ ' but got ' +
156
156
i ( header ) ,
157
157
value ,
158
- header ,
158
+ header
159
159
) ;
160
160
} else {
161
161
this . assert (
@@ -164,11 +164,11 @@ export default function (chai, _) {
164
164
key +
165
165
"' to have value " +
166
166
value +
167
- " but got " +
167
+ ' but got ' +
168
168
i ( header ) ,
169
169
"expected header '" + key + "' to not have value " + value ,
170
170
value ,
171
- header ,
171
+ header
172
172
) ;
173
173
}
174
174
} ) ;
@@ -192,11 +192,11 @@ export default function (chai, _) {
192
192
* @api public
193
193
*/
194
194
195
- Assertion . addProperty ( " headers" , function ( ) {
195
+ Assertion . addProperty ( ' headers' , function ( ) {
196
196
this . assert (
197
197
this . _obj . headers || this . _obj . getHeader ,
198
- " expected #{this} to have headers or getHeader method" ,
199
- " expected #{this} to not have headers or getHeader method" ,
198
+ ' expected #{this} to have headers or getHeader method' ,
199
+ ' expected #{this} to not have headers or getHeader method'
200
200
) ;
201
201
} ) ;
202
202
@@ -214,11 +214,11 @@ export default function (chai, _) {
214
214
* @api public
215
215
*/
216
216
217
- Assertion . addProperty ( "ip" , function ( ) {
217
+ Assertion . addProperty ( 'ip' , function ( ) {
218
218
this . assert (
219
219
net . isIP ( this . _obj ) ,
220
- " expected #{this} to be an ip" ,
221
- " expected #{this} to not be an ip" ,
220
+ ' expected #{this} to be an ip' ,
221
+ ' expected #{this} to not be an ip'
222
222
) ;
223
223
} ) ;
224
224
@@ -244,13 +244,13 @@ export default function (chai, _) {
244
244
245
245
Assertion . addProperty ( name , function ( ) {
246
246
new Assertion ( this . _obj ) . to . have . headers ;
247
- const ct = getHeader ( this . _obj , " content-type" ) ,
248
- ins = i ( ct ) === " undefined" ? " headers" : i ( ct ) ;
247
+ const ct = getHeader ( this . _obj , ' content-type' ) ,
248
+ ins = i ( ct ) === ' undefined' ? ' headers' : i ( ct ) ;
249
249
250
250
this . assert (
251
251
ct && ~ ct . indexOf ( val ) ,
252
- " expected " + ins + " to include '" + val + "'" ,
253
- " expected " + ins + " to not include '" + val + "'" ,
252
+ ' expected ' + ins + " to include '" + val + "'" ,
253
+ ' expected ' + ins + " to not include '" + val + "'"
254
254
) ;
255
255
} ) ;
256
256
}
@@ -270,7 +270,7 @@ export default function (chai, _) {
270
270
* @api public
271
271
*/
272
272
273
- Assertion . addMethod ( " charset" , function ( value ) {
273
+ Assertion . addMethod ( ' charset' , function ( value ) {
274
274
value = value . toLowerCase ( ) ;
275
275
276
276
const headers = this . _obj . headers ;
@@ -280,14 +280,14 @@ export default function (chai, _) {
280
280
* Fix charset() treating "utf8" as a special case
281
281
* See https://github.com/node-modules/charset/issues/12
282
282
*/
283
- if ( cs === " utf8" ) {
284
- cs = " utf-8" ;
283
+ if ( cs === ' utf8' ) {
284
+ cs = ' utf-8' ;
285
285
}
286
286
287
287
this . assert (
288
288
cs != null && value === cs ,
289
- " expected content type to have " + value + " charset" ,
290
- " expected content type to not have " + value + " charset" ,
289
+ ' expected content type to have ' + value + ' charset' ,
290
+ ' expected content type to not have ' + value + ' charset'
291
291
) ;
292
292
} ) ;
293
293
@@ -304,15 +304,15 @@ export default function (chai, _) {
304
304
* @api public
305
305
*/
306
306
307
- Assertion . addProperty ( " redirect" , function ( ) {
307
+ Assertion . addProperty ( ' redirect' , function ( ) {
308
308
const redirectCodes = [ 301 , 302 , 303 , 307 , 308 ] ,
309
309
status = this . _obj . status ,
310
310
redirects = this . _obj . redirects ;
311
311
312
312
this . assert (
313
313
redirectCodes . indexOf ( status ) >= 0 || ( redirects && redirects . length ) ,
314
- " expected redirect with 30X status code but got " + status ,
315
- " expected not to redirect but got " + status + " status" ,
314
+ ' expected redirect with 30X status code but got ' + status ,
315
+ ' expected not to redirect but got ' + status + ' status'
316
316
) ;
317
317
} ) ;
318
318
@@ -330,36 +330,36 @@ export default function (chai, _) {
330
330
* @api public
331
331
*/
332
332
333
- Assertion . addMethod ( " redirectTo" , function ( destination ) {
333
+ Assertion . addMethod ( ' redirectTo' , function ( destination ) {
334
334
const redirects = this . _obj . redirects ;
335
335
336
336
new Assertion ( this . _obj ) . to . redirect ;
337
337
338
338
if ( redirects && redirects . length ) {
339
339
let hasRedirected ;
340
340
341
- if ( Object . prototype . toString . call ( destination ) === " [object RegExp]" ) {
341
+ if ( Object . prototype . toString . call ( destination ) === ' [object RegExp]' ) {
342
342
hasRedirected = redirects . some ( ( redirect ) =>
343
- destination . test ( redirect ) ,
343
+ destination . test ( redirect )
344
344
) ;
345
345
} else {
346
346
hasRedirected = redirects . indexOf ( destination ) > - 1 ;
347
347
}
348
348
this . assert (
349
349
hasRedirected ,
350
- " expected redirect to " +
350
+ ' expected redirect to ' +
351
351
destination +
352
- " but got " +
353
- redirects . join ( " then " ) ,
354
- " expected not to redirect to " +
352
+ ' but got ' +
353
+ redirects . join ( ' then ' ) ,
354
+ ' expected not to redirect to ' +
355
355
destination +
356
- " but got " +
357
- redirects . join ( " then " ) ,
356
+ ' but got ' +
357
+ redirects . join ( ' then ' )
358
358
) ;
359
359
} else {
360
360
const assertion = new Assertion ( this . _obj ) ;
361
361
_ . transferFlags ( this , assertion ) ;
362
- assertion . with . header ( " location" , destination ) ;
362
+ assertion . with . header ( ' location' , destination ) ;
363
363
}
364
364
} ) ;
365
365
@@ -381,7 +381,7 @@ export default function (chai, _) {
381
381
* @api public
382
382
*/
383
383
384
- Assertion . addMethod ( " param" , function ( name , value ) {
384
+ Assertion . addMethod ( ' param' , function ( name , value ) {
385
385
const assertion = new Assertion ( ) ;
386
386
_ . transferFlags ( this , assertion ) ;
387
387
assertion . _obj = qs . parse ( url . parse ( this . _obj . url ) . query ) ;
@@ -412,12 +412,12 @@ export default function (chai, _) {
412
412
* @api public
413
413
*/
414
414
415
- Assertion . addMethod ( " cookie" , function ( key , value ) {
416
- let header = getHeader ( this . _obj , " set-cookie" ) ,
415
+ Assertion . addMethod ( ' cookie' , function ( key , value ) {
416
+ let header = getHeader ( this . _obj , ' set-cookie' ) ,
417
417
cookie ;
418
418
419
419
if ( ! header ) {
420
- header = ( getHeader ( this . _obj , " cookie" ) || "" ) . split ( ";" ) ;
420
+ header = ( getHeader ( this . _obj , ' cookie' ) || '' ) . split ( ';' ) ;
421
421
}
422
422
423
423
if ( this . _obj instanceof chai . request . agent && this . _obj . jar ) {
@@ -434,13 +434,13 @@ export default function (chai, _) {
434
434
"expected cookie '" + key + "' to have value #{exp} but got #{act}" ,
435
435
"expected cookie '" + key + "' to not have value #{exp}" ,
436
436
value ,
437
- cookie . value ,
437
+ cookie . value
438
438
) ;
439
439
} else {
440
440
this . assert (
441
- " undefined" !== typeof cookie || null === cookie ,
441
+ ' undefined' !== typeof cookie || null === cookie ,
442
442
"expected cookie '" + key + "' to exist" ,
443
- "expected cookie '" + key + "' to not exist" ,
443
+ "expected cookie '" + key + "' to not exist"
444
444
) ;
445
445
}
446
446
} ) ;
0 commit comments