summaryrefslogtreecommitdiffstats
path: root/spec/javascript-compiler.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2013-12-23 21:00:59 -0600
committerkpdecker <kpdecker@gmail.com>2013-12-23 21:00:59 -0600
commitbbc7c7d080445791e4c46224f617504f303a0ac6 (patch)
tree77a94275acd790f7fd88657dc0945124afe16147 /spec/javascript-compiler.js
parent1a751b2f6ea71a0bf87f36e529a718474282bb7c (diff)
downloadhandlebars.js-bbc7c7d080445791e4c46224f617504f303a0ac6.zip
handlebars.js-bbc7c7d080445791e4c46224f617504f303a0ac6.tar.gz
handlebars.js-bbc7c7d080445791e4c46224f617504f303a0ac6.tar.bz2
Expose compilerInfo and checkRevision as APIs
Fixes #656
Diffstat (limited to 'spec/javascript-compiler.js')
-rw-r--r--spec/javascript-compiler.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/javascript-compiler.js b/spec/javascript-compiler.js
index ded4f3e..884abf1 100644
--- a/spec/javascript-compiler.js
+++ b/spec/javascript-compiler.js
@@ -20,6 +20,28 @@ describe('javascript-compiler api', function() {
shouldCompileTo("{{foo}}", { bar_foo: "food" }, "food");
});
});
+ describe('#compilerInfo', function() {
+ var $superCheck, $superInfo;
+ beforeEach(function() {
+ $superCheck = handlebarsEnv.VM.checkRevision;
+ $superInfo = handlebarsEnv.JavaScriptCompiler.prototype.compilerInfo;
+ });
+ afterEach(function() {
+ handlebarsEnv.VM.checkRevision = $superCheck;
+ handlebarsEnv.JavaScriptCompiler.prototype.compilerInfo = $superInfo;
+ });
+ it('should allow compilerInfo override', function() {
+ handlebarsEnv.JavaScriptCompiler.prototype.compilerInfo = function() {
+ return 'this.compilerInfo = "crazy";';
+ };
+ handlebarsEnv.VM.checkRevision = function(compilerInfo) {
+ if (compilerInfo !== 'crazy') {
+ throw new Error('It didn\'t work');
+ }
+ };
+ shouldCompileTo("{{foo}} ", { foo: "food" }, "food ");
+ });
+ });
describe('buffer', function() {
var $superAppend, $superCreate;
beforeEach(function() {