Skip to content

Instantly share code, notes, and snippets.

@ben-eb
Last active August 29, 2015 13:57
Show Gist options
  • Save ben-eb/9925808 to your computer and use it in GitHub Desktop.
Save ben-eb/9925808 to your computer and use it in GitHub Desktop.
Test for gulp clone.
var expect = require('chai').expect,
through = require('through2'),
gutil = require('gulp-util'),
clone = require('./');
describe('gulp-clone', function() {
it('should clone files in the stream', function(done) {
var sourceStream = clone(),
cloneStream = clone();
sourceStream.pipe(cloneStream);
sourceStream.on('data', function(data) {
expect(String(data.contents)).to.be.equal('source stream');
expect(data.path).to.be.equal('file.js');
});
cloneStream.pipe(through.obj(function(file, enc, cb) {
file.contents = new Buffer('cloned stream');
cb(null, file);
}))
cloneStream.on('data', function(data) {
expect(String(data.contents)).to.be.equal('cloned stream');
expect(data.path).to.be.equal('file.js');
});
sourceStream.write(new gutil.File({
path: 'file.js',
contents: new Buffer('source stream')
}));
sourceStream.on('finish', done);
sourceStream.end();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment