mirror of https://github.com/zulip/zulip.git
node tests: Fix make_sure_all_templates_have_been_compiled().
This now searches subdirectories.
This commit is contained in:
parent
3d0c0e2e81
commit
dae53573cb
|
@ -16,15 +16,11 @@ exports.init = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.make_sure_all_templates_have_been_compiled = function () {
|
exports.make_sure_all_templates_have_been_compiled = function () {
|
||||||
var dir = template_dir();
|
var files = exports.template_finder.get_all();
|
||||||
var fns = fs.readdirSync(dir).filter(function (fn) {
|
|
||||||
return (/\.handlebars/).test(fn);
|
|
||||||
});
|
|
||||||
|
|
||||||
_.each(fns, function (fn) {
|
_.each(files, function (file) {
|
||||||
var name = fn.split('.')[0];
|
if (!Handlebars.templates[file.name]) {
|
||||||
if (!Handlebars.templates[name]) {
|
throw "The file " + file.url + " has no test coverage.";
|
||||||
throw "The file " + fn + " has no test coverage.";
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -88,12 +84,17 @@ exports.template_finder = (function () {
|
||||||
var self = {};
|
var self = {};
|
||||||
|
|
||||||
// get all files and then map them into friendlier names.
|
// get all files and then map them into friendlier names.
|
||||||
var files = exports.walk(template_dir()).map(function (file) {
|
var all_files = exports.walk(template_dir());
|
||||||
return {
|
var files = all_files
|
||||||
url: file.url,
|
.filter(function (file) {
|
||||||
name: file.name.replace(/\.handlebars$/, "")
|
return (/\.handlebars$/).test(file.name);
|
||||||
};
|
})
|
||||||
});
|
.map(function (file) {
|
||||||
|
return {
|
||||||
|
url: file.url,
|
||||||
|
name: file.name.replace(/\.handlebars$/, "")
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
self.get = function (name) {
|
self.get = function (name) {
|
||||||
var file = files.find(function (file) {
|
var file = files.find(function (file) {
|
||||||
|
@ -104,6 +105,10 @@ exports.template_finder = (function () {
|
||||||
return file;
|
return file;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.get_all = function () {
|
||||||
|
return files;
|
||||||
|
};
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue