Skip to content

Commit

Permalink
Groups options test and removes file existence check
Browse files Browse the repository at this point in the history
  • Loading branch information
Gromych committed Mar 3, 2016
1 parent 682dc61 commit a96a72e
Showing 1 changed file with 34 additions and 37 deletions.
71 changes: 34 additions & 37 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,50 +215,47 @@ describe('gulp-replace', function() {
});
});

it('should ignore binary files when skipBinary is enabled', function(done) {
var file = new File({
path: 'test/fixtures/binary.png',
cwd: 'test/',
base: 'test/fixtures',
contents: fs.readFileSync('test/fixtures/binary.png')
});
describe('options', function () {
describe('skipBinary', function () {
it('should ignore binary files when skipBinary is enabled', function(done) {
var file = new File({
path: 'test/fixtures/binary.png',
cwd: 'test/',
base: 'test/fixtures',
contents: fs.readFileSync('test/fixtures/binary.png')
});

var stream = replacePlugin('world', 'person', {skipBinary: true});
stream.on('data', function(newFile) {
should.exist(newFile);
should.exist(newFile.contents);
var stream = replacePlugin('world', 'person', {skipBinary: true});
stream.on('data', function(newFile) {
newFile.contents.should.eql(fs.readFileSync('test/expected/binary.png'));
done();
});

newFile.contents.should.eql(fs.readFileSync('test/expected/binary.png'));
done();
});
stream.write(file);
stream.end();
});

stream.write(file);
stream.end();
});
it('should replace string on non binary files when skipBinary is enabled', function(done) {
var file = new File({
path: 'test/fixtures/helloworld.txt',
cwd: 'test/',
base: 'test/fixtures',
contents: fs.createReadStream('test/fixtures/helloworld.txt')
});

it('should replace string on non binary files when skipBinary is enabled', function(done) {
var file = new File({
path: 'test/fixtures/helloworld.txt',
cwd: 'test/',
base: 'test/fixtures',
contents: fs.createReadStream('test/fixtures/helloworld.txt')
});
var stream = replacePlugin('world', 'person', {skipBinary: true});
stream.on('data', function(newFile) {
newFile.contents.pipe(concatStream({encoding: 'string'}, function(data) {
data.should.equal(fs.readFileSync('test/expected/helloworld.txt', 'utf8'));
done();
}));
});

var stream = replacePlugin('world', 'person', {skipBinary: true});
stream.on('data', function(newFile) {
should.exist(newFile);
should.exist(newFile.contents);
stream.write(file);
stream.end();
});

newFile.contents.pipe(concatStream({encoding: 'string'}, function(data) {
data.should.equal(fs.readFileSync('test/expected/helloworld.txt', 'utf8'));
done();
}));
});

stream.write(file);
stream.end();
});


});
});

0 comments on commit a96a72e

Please sign in to comment.