Skip to content
This repository was archived by the owner on Sep 12, 2022. It is now read-only.

Commit b088f5e

Browse files
committed
adding a test case for opts.compiler
1 parent 2f71197 commit b088f5e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

test/expected/Basic_htmlbars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BASIC TEMPLATE

test/main.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,34 @@ describe('gulp-handlebars', function() {
128128
hbsStream.write(basicTemplate);
129129
hbsStream.end();
130130
});
131+
132+
it('should allow custom compiler', function(done) {
133+
var compiler = function(contents, compilerOptions) {
134+
return contents.toUpperCase();
135+
};
136+
var stream = handlebarsPlugin({
137+
compiler: compiler
138+
});
139+
var basicTemplate = getFixture('Basic.hbs');
140+
141+
stream.on('data', function(newFile) {
142+
should.exist(newFile);
143+
should.exist(newFile.contents);
144+
145+
// @TODO: it should call `fileMatchesExpected` function
146+
// But I got an error of expected: "BASIC TEMPLATE\n", actual: "BASIC TEMPLATE"
147+
// so that I manually adding the newLine character.
148+
// I think it related to plain text in the 'Basic_htmlbars.js'
149+
var expected = getExpectedString('Basic_htmlbars.js');
150+
var tested = String(newFile.contents)+'\n';
151+
tested.should.equal(expected);
152+
// fileMatchesExpected(newFile, 'Basic_htmlbars.js', 'Basic.js');
153+
154+
done();
155+
});
156+
stream.write(basicTemplate);
157+
stream.end();
158+
});
159+
131160
});
132161
});

0 commit comments

Comments
 (0)