Skip to content

Commit

Permalink
Test that gulp-rename works for parallel streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Josiah committed Aug 25, 2015
1 parent fb1a8e3 commit 5001e08
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/rename.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
/* global helper, helperError */

require('./spec-helper');
var rename = require('../');
var gulp = require('gulp');
var Path = require('path');

describe('gulp-rename', function () {
context('with string parameter', function () {
Expand Down Expand Up @@ -172,6 +175,50 @@ describe('gulp-rename', function () {
});
});

context('in parallel streams', function () {
it('only changes the file in the current stream', function (done) {
var files = gulp.src('test/fixtures/hello.txt');

var pipe1 = files.pipe(rename({suffix: '-1'}));
var pipe2 = files.pipe(rename({suffix: '-2'}));
var end1 = false;
var end2 = false;
var file1;
var file2;

pipe1
.on('data', function (file) {
file1 = file;
})
.on('end', function () {
end1 = true;

if (end2) {
return check();
}
});

pipe2
.on('data', function (file) {
file2 = file;
})
.on('end', function () {
end2 = true;

if (end1) {
return check();
}
});

function check() {
file1.path.should.equal(Path.resolve('test/fixtures/hello-1.txt'));
file2.path.should.equal(Path.resolve('test/fixtures/hello-2.txt'));

return done();
}
});
});

context('throws unsupported parameter type', function () {
var srcPattern;
beforeEach(function () {
Expand Down

0 comments on commit 5001e08

Please sign in to comment.