Add mustache spec to tests
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
[submodule "spec/mustache"]
|
||||
path = spec/mustache
|
||||
url = git@github.com:mustache/spec.git
|
||||
Submodule
+1
Submodule spec/mustache added at 72233f3ffd
@@ -0,0 +1,49 @@
|
||||
describe('spec', function() {
|
||||
// NOP Under non-node environments
|
||||
if (typeof process === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
var _ = require('underscore'),
|
||||
Handlebars = require('../lib'),
|
||||
fs = require('fs');
|
||||
|
||||
var specDir =__dirname + '/mustache/specs/';
|
||||
var specs = _.filter(fs.readdirSync(specDir), function(name) {
|
||||
return /.*\.json$/.test(name);
|
||||
});
|
||||
|
||||
_.each(specs, function(name) {
|
||||
var spec = require(specDir + name);
|
||||
_.each(spec.tests, function(test) {
|
||||
// Our lambda implementation knowingly deviates from the optional Mustace lambda spec
|
||||
// We also do not support alternative delimeters
|
||||
if (name === '~lambdas.json'
|
||||
|
||||
// We also choose to throw if paritals are not found
|
||||
|| (name === 'partials.json' && test.name === 'Failed Lookup')
|
||||
|
||||
// We nest the entire response from partials, not just the literals
|
||||
|| (name === 'partials.json' && test.name === 'Standalone Indentation')
|
||||
|
||||
|| /\{\{\=/.test(test.template)
|
||||
|| _.any(test.partials, function(partial) { return /\{\{\=/.test(partial); })) {
|
||||
it.skip(name + ' - ' + test.name);
|
||||
return;
|
||||
}
|
||||
|
||||
var data = _.clone(test.data);
|
||||
if (data.lambda) {
|
||||
// Blergh
|
||||
data.lambda = eval('(' + data.lambda.js + ')');
|
||||
}
|
||||
it(name + ' - ' + test.name, function() {
|
||||
if (test.partials) {
|
||||
shouldCompileToWithPartials(test.template, [data, {}, test.partials, true], true, test.expected, test.desc + ' "' + test.template + '"');
|
||||
} else {
|
||||
shouldCompileTo(test.template, [data, {}, {}, true], test.expected, test.desc + ' "' + test.template + '"');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user