Skip to content

Commit

Permalink
Move pipeTo test to piping.js tests file.
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Apr 21, 2014
1 parent 7cddcd4 commit 87c43b2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
27 changes: 1 addition & 26 deletions reference-implementation/test/base-readable-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,32 +402,6 @@ test('BaseReadableStream should be able to get data sequentially from an asynchr
.catch(t.ifError.bind(t));
});

test('BaseReadableStream pipeTo should complete successfully upon asynchronous finish', function (t) {
// https://github.com/whatwg/streams/issues/80

t.plan(1);

var stream = sequentialBaseReadableStream(5, { async: true });

var dataWritten = [];
var dest = {
state: 'writable',
write: function (value) {
dataWritten.push(value);
return Promise.resolve();
},
close: function () {
t.deepEqual(dataWritten, [1, 2, 3, 4, 5]);
return Promise.resolve();
},
abort: function () {
t.fail('Should not call abort');
}
};

stream.pipeTo(dest);
});

test('BaseReadableStream cancellation puts the stream in a closed state (no data pulled yet)', function (t) {
var stream = sequentialBaseReadableStream(5);

Expand Down Expand Up @@ -459,6 +433,7 @@ test('BaseReadableStream cancellation puts the stream in a closed state (no data
t.fail('wait promise vended after the cancellation should not be rejected');
});
});

test('BaseReadableStream cancellation puts the stream in a closed state (after waiting for data)', function (t) {
var stream = sequentialBaseReadableStream(5);

Expand Down
27 changes: 27 additions & 0 deletions reference-implementation/test/piping.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
'use strict';

var test = require('tape');
var Promise = require('es6-promise').Promise;
var readableStreamToArray = require('./lib/readable-stream-to-array.js');
var sequentialBaseReadableStream = require('./lib/sequential-brs.js');
var passThroughTransform = require('./lib/pass-through-transform.js');

require('../index.js');

test('BaseReadableStream pipeTo should complete successfully upon asynchronous finish', function (t) {
// https://github.com/whatwg/streams/issues/80

t.plan(1);

var stream = sequentialBaseReadableStream(5, { async: true });

var dataWritten = [];
var dest = {
state: 'writable',
write: function (value) {
dataWritten.push(value);
return Promise.resolve();
},
close: function () {
t.deepEqual(dataWritten, [1, 2, 3, 4, 5]);
return Promise.resolve();
},
abort: function () {
t.fail('Should not call abort');
}
};

stream.pipeTo(dest);
});

test('Piping through a pass-through transform stream works', function (t) {
t.plan(1);

Expand Down

0 comments on commit 87c43b2

Please sign in to comment.