Skip to content

Commit

Permalink
Added flatten variables test
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Jun 19, 2015
1 parent 71d9eab commit 2c1f351
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
6 changes: 5 additions & 1 deletion package.json
Expand Up @@ -42,5 +42,9 @@
"gulp-util": "^3.0.4",
"merge": "^1.2.0",
"through2": "^2.0.0"
}
},
"files": [
"index.js",
"Readme.md"
]
}
3 changes: 3 additions & 0 deletions test/fixtures-flatten/index.html
@@ -0,0 +1,3 @@
<label>@@obj</label>
<strong>@@obj.param1</strong>
<strong>@@obj.param2</strong>
3 changes: 3 additions & 0 deletions test/fixtures-flatten/result.html
@@ -0,0 +1,3 @@
<label>@@obj</label>
<strong>value1</strong>
<strong>value2</strong>
64 changes: 64 additions & 0 deletions test/flatten.js
@@ -0,0 +1,64 @@
'use strict';

var fileIncludePlugin = require('..'),
gutil = require('gulp-util'),
should = require('should'),
fs = require('fs');

describe('## gulp-file-include', function() {
var result = fs.readFileSync('test/fixtures-flatten/result.html', 'utf8');

describe('# flatten variables', function() {
it('file', function(done) {
var file = new gutil.File({
path: 'test/fixtures-flatten/index.html',
contents: fs.readFileSync('test/fixtures-flatten/index.html')
});

var stream = fileIncludePlugin({
context: {
obj: {
'param1': 'value1',
'param2': 'value2'
}
}
});
stream.on('data', function(newFile) {
should.exist(newFile);
should.exist(newFile.contents);

String(newFile.contents).should.equal(result);
done();
});

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

it('stream', function(done) {
var file = new gutil.File({
path: 'test/fixtures-flatten/index.html',
contents: fs.createReadStream('test/fixtures-flatten/index.html')
});

var stream = fileIncludePlugin({
context: {
obj: {
'param1': 'value1',
'param2': 'value2'
}
}
});
stream.on('data', function(newFile) {
should.exist(newFile);
should.exist(newFile.contents);

String(newFile.contents).should.equal(result);
done();
});

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

0 comments on commit 2c1f351

Please sign in to comment.