Skip to content

Commit

Permalink
adding a test case for opts.compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
mattma committed Dec 15, 2014
1 parent 2f71197 commit b088f5e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/expected/Basic_htmlbars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BASIC TEMPLATE
29 changes: 29 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,34 @@ describe('gulp-handlebars', function() {
hbsStream.write(basicTemplate);
hbsStream.end();
});

it('should allow custom compiler', function(done) {
var compiler = function(contents, compilerOptions) {
return contents.toUpperCase();
};
var stream = handlebarsPlugin({
compiler: compiler
});
var basicTemplate = getFixture('Basic.hbs');

stream.on('data', function(newFile) {
should.exist(newFile);
should.exist(newFile.contents);

// @TODO: it should call `fileMatchesExpected` function
// But I got an error of expected: "BASIC TEMPLATE\n", actual: "BASIC TEMPLATE"
// so that I manually adding the newLine character.
// I think it related to plain text in the 'Basic_htmlbars.js'
var expected = getExpectedString('Basic_htmlbars.js');
var tested = String(newFile.contents)+'\n';
tested.should.equal(expected);
// fileMatchesExpected(newFile, 'Basic_htmlbars.js', 'Basic.js');

done();
});
stream.write(basicTemplate);
stream.end();
});

});
});

0 comments on commit b088f5e

Please sign in to comment.