Commit cc57627b authored by analog-nico's avatar analog-nico
Browse files

Added test for using pipes and the promise at the same time

parent ee0a8b35
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@
  "devDependencies": {
  "devDependencies": {
    "chai": "^1.10.0",
    "chai": "^1.10.0",
    "chai-as-promised": "^4.1.1",
    "chai-as-promised": "^4.1.1",
    "event-stream": "^3.1.7",
    "gulp": "^3.8.10",
    "gulp": "^3.8.10",
    "gulp-istanbul": "^0.3.1",
    "gulp-istanbul": "^0.3.1",
    "gulp-jshint": "^1.9.0",
    "gulp-jshint": "^1.9.0",
+19 −1
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@ var url = require('url');
var Bluebird = require('bluebird');
var Bluebird = require('bluebird');
var childProcess = require('child_process');
var childProcess = require('child_process');
var path = require('path');
var path = require('path');
var es = require('event-stream');




describe('Request-Promise', function () {
describe('Request-Promise', function () {
@@ -834,7 +835,7 @@ describe('Request-Promise', function () {
            });
            });
        });
        });


        it('for registering to the emitted complete event', function (done) {
        it('for registering a handler to the emitted complete event', function (done) {
            rp('http://localhost:4000/200')
            rp('http://localhost:4000/200')
                .on('complete', function (httpResponse, body) {
                .on('complete', function (httpResponse, body) {
                    expect(httpResponse.statusCode).to.eql(200);
                    expect(httpResponse.statusCode).to.eql(200);
@@ -843,6 +844,23 @@ describe('Request-Promise', function () {
                });
                });
        });
        });


        it('for piping data while also the promise is used', function (done) {

            var req = rp('http://localhost:4000/200');

            var _data;
            req.pipe(es.wait(function (err, data) {
                    _data = data.toString();
                }));

            req.then(function (body) {
                    expect(body).to.eql('GET /200');
                    expect(_data).to.eql('GET /200');
                    done();
                });

        });

        it('for requests with a redirect', function () {
        it('for requests with a redirect', function () {


            return rp('http://localhost:4000/302')
            return rp('http://localhost:4000/302')