1 var common = require('../common');
2 var assert = common.assert;
3 var CombinedStream = common.CombinedStream;
4 var fs = require('fs');
6 var FILE1 = common.dir.fixture + '/file1.txt';
7 var FILE2 = common.dir.fixture + '/file2.txt';
8 var EXPECTED = fs.readFileSync(FILE1) + fs.readFileSync(FILE2);
10 (function testDelayedStreams() {
11 var combinedStream = CombinedStream.create({pauseStreams: false});
12 combinedStream.append(fs.createReadStream(FILE1));
13 combinedStream.append(fs.createReadStream(FILE2));
15 var stream1 = combinedStream._streams[0];
16 var stream2 = combinedStream._streams[1];
18 stream1.on('end', function() {
19 assert.ok(stream2.dataSize > 0);
22 var tmpFile = common.dir.tmp + '/combined.txt';
23 var dest = fs.createWriteStream(tmpFile);
24 combinedStream.pipe(dest);
26 dest.on('end', function() {
27 var written = fs.readFileSync(tmpFile, 'utf8');
28 assert.strictEqual(written, EXPECTED);