@@ -191,9 +191,6 @@ module.exports = function (app) {
191
191
module . exports . Test = Test ;
192
192
module . exports . Request = Test ;
193
193
module . exports . agent = TestAgent ;
194
- module . exports . addPromises = function ( Promise ) {
195
- Test . Promise = Promise ;
196
- } ;
197
194
198
195
/*!
199
196
* Test
@@ -214,77 +211,6 @@ function Test (app, method, path) {
214
211
this . url = typeof app === 'string' ? app + path : serverAddress ( app , path ) ;
215
212
}
216
213
util . inherits ( Test , Request ) ;
217
- Test . Promise = global . Promise ;
218
-
219
- /**
220
- * ### .then (resolveCb, rejectCb)
221
- *
222
- * Invoke the request to to the server. The response
223
- * will be passed as a parameter to the resolveCb,
224
- * while any errors will be passed to rejectCb.
225
- *
226
- * ```js
227
- * chai.request(app)
228
- * .get('/')
229
- * .then(function (res) {
230
- * expect(res).to.have.status(200);
231
- * }, function (err) {
232
- * throw err;
233
- * });
234
- * ```
235
- *
236
- * @param {Function } resolveCB
237
- * @cb {Response}
238
- * @param {Function } rejectCB
239
- * @cb {Error}
240
- * @name then
241
- * @api public
242
- */
243
-
244
- Test . prototype . then = function ( onResolve , onReject ) {
245
- if ( ! Test . Promise ) {
246
- throw new Error ( 'Tried to use chai-http with promises, but no Promise library set' ) ;
247
- }
248
- if ( ! this . _promise ) {
249
- var self = this ;
250
- this . _promise = new Test . Promise ( function ( resolve , reject ) {
251
- self . end ( function ( err , res ) {
252
- if ( err ) {
253
- reject ( err ) ;
254
- } else {
255
- resolve ( res ) ;
256
- }
257
- } ) ;
258
- } ) ;
259
- }
260
- this . _promise = this . _promise . then ( onResolve , onReject ) ;
261
- return this ;
262
- } ;
263
-
264
- /**
265
- * ### .catch (rejectCb)
266
- *
267
- * Invoke the request to to the server, catching any
268
- * errors with this callback. Behaves the same as
269
- * Promises.
270
- *
271
- * ```js
272
- * chai.request(app)
273
- * .get('/')
274
- * .catch(function (err) {
275
- * throw err;
276
- * });
277
- * ```
278
- *
279
- * @param {Function } rejectCB
280
- * @cb {Error}
281
- * @name catch
282
- * @api public
283
- */
284
-
285
- Test . prototype . catch = function ( reject ) {
286
- return this . then ( undefined , reject ) ;
287
- } ;
288
214
289
215
function serverAddress ( app , path ) {
290
216
if ( 'string' === typeof app ) {
@@ -332,11 +258,11 @@ methods.forEach(function(method){
332
258
333
259
if ( Agent ) {
334
260
// When running in Node, cookies are managed via
335
- // `Agent.saveCookies ()` and `Agent.attachCookies ()`.
336
- req . on ( 'response' , function ( res ) { self . saveCookies ( res ) ; } ) ;
337
- req . on ( 'redirect' , function ( res ) { self . saveCookies ( res ) ; } ) ;
338
- req . on ( 'redirect' , function ( ) { self . attachCookies ( req ) ; } ) ;
339
- this . attachCookies ( req ) ;
261
+ // `Agent._saveCookies ()` and `Agent._attachCookies ()`.
262
+ req . on ( 'response' , function ( res ) { self . _saveCookies ( res ) ; } ) ;
263
+ req . on ( 'redirect' , function ( res ) { self . _saveCookies ( res ) ; } ) ;
264
+ req . on ( 'redirect' , function ( ) { self . _attachCookies ( req ) ; } ) ;
265
+ this . _attachCookies ( req ) ;
340
266
}
341
267
else {
342
268
// When running in a web browser, cookies are managed via `Request.withCredentials()`.
0 commit comments