Skip to content

Commit 3083ab1

Browse files
authoredJun 10, 2016
Merge pull request #99 from keithamus/update-all-the-things
Update all the things
2 parents 3626212 + 6d73652 commit 3083ab1

File tree

4 files changed

+17
-92
lines changed

4 files changed

+17
-92
lines changed
 

‎.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22
node_js:
3-
- 0.1
4-
- 0.11
3+
- 4
4+
- stable
55
deploy:
66
provider: npm
77
email:

‎lib/request.js

+5-79
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@ module.exports = function (app) {
191191
module.exports.Test = Test;
192192
module.exports.Request = Test;
193193
module.exports.agent = TestAgent;
194-
module.exports.addPromises = function (Promise) {
195-
Test.Promise = Promise;
196-
};
197194

198195
/*!
199196
* Test
@@ -214,77 +211,6 @@ function Test (app, method, path) {
214211
this.url = typeof app === 'string' ? app + path : serverAddress(app, path);
215212
}
216213
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-
};
288214

289215
function serverAddress (app, path) {
290216
if ('string' === typeof app) {
@@ -332,11 +258,11 @@ methods.forEach(function(method){
332258

333259
if (Agent) {
334260
// 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);
340266
}
341267
else {
342268
// When running in a web browser, cookies are managed via `Request.withCredentials()`.

‎package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@
4848
"dependencies": {
4949
"cookiejar": "2.0.x",
5050
"is-ip": "1.0.0",
51-
"methods": "0.0.x",
52-
"qs": "2.0.x",
53-
"superagent": "1.2.x"
51+
"methods": "^1.1.2",
52+
"qs": "^6.2.0",
53+
"superagent": "^2.0.0"
5454
},
5555
"devDependencies": {
5656
"simplifyify": "^2.0.1",
5757
"chai": "*",
58-
"coveralls": "^2.11.6",
59-
"dox": "*",
60-
"es6-shim": "*",
61-
"http-server": "*",
62-
"istanbul": "^0.4.2",
63-
"mocha": "*",
64-
"npm-run-all": "^1.5.1"
58+
"coveralls": "^2.11.9",
59+
"dox": "^0.8.1",
60+
"es6-shim": "^0.35.1",
61+
"http-server": "^0.9.0",
62+
"istanbul": "^0.4.3",
63+
"mocha": "^2.5.3",
64+
"npm-run-all": "^2.1.1"
6565
},
6666
"engines": {
6767
"node": ">= 0.6.0"

‎test/request.js

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ describe('request', function () {
22
var isNode = typeof process === 'object';
33
var isBrowser = typeof window === 'object';
44
var request = chai.request;
5-
request.addPromises(Promise);
65

76
describe('Browser and Node.js', function () {
87
it('is present on chai', function () {

0 commit comments

Comments
 (0)
Please sign in to comment.