Skip to content
Permalink
Browse files

Merge branch '4.x'

# Conflicts:
#	integration-testing/multi-nodejs-test/test.sh
#	spec/string-params.js
#	spec/subexpressions.js
#	spec/track-ids.js
  • Loading branch information
nknapp committed May 4, 2020
2 parents a65a553 + 77825f8 commit 212f9d930b1a39599da2646ac23da64f6552b9d0
Showing with 2,924 additions and 3,581 deletions.
  1. +389 −401 spec/basic.js
  2. +288 −337 spec/blocks.js
  3. +447 −443 spec/builtins.js
  4. +158 −244 spec/data.js
  5. +40 −7 spec/env/common.js
  6. +520 −815 spec/helpers.js
  7. +15 −5 spec/javascript-compiler.js
  8. +442 −606 spec/partials.js
  9. +217 −244 spec/regressions.js
  10. +22 −44 spec/security.js
  11. +6 −16 spec/spec.js
  12. +98 −164 spec/strict.js
  13. +161 −163 spec/subexpressions.js
  14. +3 −5 spec/utils.js
  15. +118 −87 spec/whitespace-control.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -129,6 +129,7 @@ function HandlebarsTestBench(templateAsString) {
this.templateAsString = templateAsString;
this.helpers = {};
this.partials = {};
this.decorators = {};
this.input = {};
this.message =
'Template' + templateAsString + ' does not evaluate to expected output';
@@ -146,11 +147,43 @@ HandlebarsTestBench.prototype.withHelper = function(name, helperFunction) {
return this;
};

HandlebarsTestBench.prototype.withHelpers = function(helperFunctions) {
var self = this;
Object.keys(helperFunctions).forEach(function(name) {
self.withHelper(name, helperFunctions[name]);
});
return this;
};

HandlebarsTestBench.prototype.withPartial = function(name, partialAsString) {
this.partials[name] = partialAsString;
return this;
};

HandlebarsTestBench.prototype.withPartials = function(partials) {
var self = this;
Object.keys(partials).forEach(function(name) {
self.withPartial(name, partials[name]);
});
return this;
};

HandlebarsTestBench.prototype.withDecorator = function(
name,
decoratorFunction
) {
this.decorators[name] = decoratorFunction;
return this;
};

HandlebarsTestBench.prototype.withDecorators = function(decorators) {
var self = this;
Object.keys(decorators).forEach(function(name) {
self.withDecorator(name, decorators[name]);
});
return this;
};

HandlebarsTestBench.prototype.withCompileOptions = function(compileOptions) {
this.compileOptions = compileOptions;
return this;
@@ -167,19 +200,18 @@ HandlebarsTestBench.prototype.withMessage = function(message) {
};

HandlebarsTestBench.prototype.toCompileTo = function(expectedOutputAsString) {
expect(this._compileAndExecute()).to.equal(expectedOutputAsString);
expect(this._compileAndExecute()).to.equal(
expectedOutputAsString,
this.message
);
};

// see chai "to.throw" (https://www.chaijs.com/api/bdd/#method_throw)
HandlebarsTestBench.prototype.toThrow = function(
errorLike,
errMsgMatcher,
msg
) {
HandlebarsTestBench.prototype.toThrow = function(errorLike, errMsgMatcher) {
var self = this;
expect(function() {
self._compileAndExecute();
}).to.throw(errorLike, errMsgMatcher, msg);
}).to.throw(errorLike, errMsgMatcher, this.message);
};

HandlebarsTestBench.prototype._compileAndExecute = function() {
@@ -202,5 +234,6 @@ HandlebarsTestBench.prototype._combineRuntimeOptions = function() {
});
combinedRuntimeOptions.helpers = this.helpers;
combinedRuntimeOptions.partials = this.partials;
combinedRuntimeOptions.decorators = this.decorators;
return combinedRuntimeOptions;
};

0 comments on commit 212f9d9

Please sign in to comment.
You can’t perform that action at this time.