From a96a72ea21ea3c33c3391da58b11ee465f324007 Mon Sep 17 00:00:00 2001 From: Gromych Date: Thu, 3 Mar 2016 22:36:21 +0300 Subject: [PATCH] Groups options test and removes file existence check --- test/main.js | 71 +++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/test/main.js b/test/main.js index b36ad6d..feb2b1c 100644 --- a/test/main.js +++ b/test/main.js @@ -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(); }); - - }); });