Skip to content

Commit

Permalink
Update: Add test for readable events
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Sep 14, 2016
1 parent 7d8af8c commit a4c3e14
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"clone": "^1.0.0",
"clone-stats": "^1.0.0",
"cloneable-readable": "^0.2.0",
"cloneable-readable": "^0.3.0",
"readable-stream": "^2.1.0",
"replace-ext": "^1.0.0"
},
Expand Down
43 changes: 43 additions & 0 deletions test/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,49 @@ describe('File', function() {
file.contents.on('end', latch);
});

it('should not start flowing until all clones flows', function(done) {
var contents = new Stream.PassThrough();
var options = {
cwd: '/',
base: '/test/',
path: '/test/test.coffee',
contents: contents,
};
var file = new File(options);
var file2 = file.clone();
var ends = 2;

function latch() {
if (--ends === 0) {
done();
}
}

contents.write(new Buffer('wa'));

process.nextTick(function() {
contents.write(new Buffer('dup'));
contents.end();
});

// Start flowing file2
file2.contents.on('readable', function() {
this.read();
});

file2.contents.once('readable', function() {
process.nextTick(function() {
// Starts flowing file
file.contents.on('readable', function() {
ends.should.equal(2);
});
});
});

file2.contents.on('end', latch);
file.contents.on('end', latch);
});

it('should copy all attributes over with null', function(done) {
var options = {
cwd: '/',
Expand Down

0 comments on commit a4c3e14

Please sign in to comment.