Loading test/spec/request-test.js +77 −1 Original line number Diff line number Diff line Loading @@ -390,7 +390,6 @@ describe('Request-Promise', function () { }); describe('defaults', function () {}); // TODO describe('examples in readme', function () {}); // TODO describe('should still allow a callback', function () { Loading Loading @@ -641,4 +640,81 @@ describe('Request-Promise', function () { }); describe('should run the examples', function () { it('in the README', function () { var options; return Bluebird.resolve() .then(function () { return rp('http://www.google.com') .then(function (body) { expect(body).to.contain('</html>'); }) .catch(function (err) { throw err; }); // --> 'GET's and displays google.com }) .then(function () { options = { uri : 'http://localhost:4000/200', method : 'POST' }; return rp(options) .then(function (body) { expect(body).to.eql('POST /200'); }) .catch(function (err) { throw err; }); // --> Displays response from server after post }) .then(function () { options.transform = function (data) { return data.length; }; return rp(options) .then(function (body) { expect(body).to.eql('POST /200'.length); }) .catch(function (err) { throw err; }); // transform is called just before promise is fulfilled // --> Displays length of response from server after post }) .then(function () { // Get full response after DELETE options = { method: 'DELETE', uri: 'http://localhost:4000/200', resolveWithFullResponse: true }; return rp(options) .then(function (response) { expect(response.statusCode).to.eql(200); }) .catch(function (err) { throw err; }); }); }); }); }); Loading
test/spec/request-test.js +77 −1 Original line number Diff line number Diff line Loading @@ -390,7 +390,6 @@ describe('Request-Promise', function () { }); describe('defaults', function () {}); // TODO describe('examples in readme', function () {}); // TODO describe('should still allow a callback', function () { Loading Loading @@ -641,4 +640,81 @@ describe('Request-Promise', function () { }); describe('should run the examples', function () { it('in the README', function () { var options; return Bluebird.resolve() .then(function () { return rp('http://www.google.com') .then(function (body) { expect(body).to.contain('</html>'); }) .catch(function (err) { throw err; }); // --> 'GET's and displays google.com }) .then(function () { options = { uri : 'http://localhost:4000/200', method : 'POST' }; return rp(options) .then(function (body) { expect(body).to.eql('POST /200'); }) .catch(function (err) { throw err; }); // --> Displays response from server after post }) .then(function () { options.transform = function (data) { return data.length; }; return rp(options) .then(function (body) { expect(body).to.eql('POST /200'.length); }) .catch(function (err) { throw err; }); // transform is called just before promise is fulfilled // --> Displays length of response from server after post }) .then(function () { // Get full response after DELETE options = { method: 'DELETE', uri: 'http://localhost:4000/200', resolveWithFullResponse: true }; return rp(options) .then(function (response) { expect(response.statusCode).to.eql(200); }) .catch(function (err) { throw err; }); }); }); }); });