diff --git a/zerver/tests/frontend/node/index.js b/zerver/tests/frontend/node/index.js index f7501765f4..660cfc9a8a 100644 --- a/zerver/tests/frontend/node/index.js +++ b/zerver/tests/frontend/node/index.js @@ -27,12 +27,29 @@ global.add_dependencies = function (dct) { }); }; +function template_dir() { + return __dirname + '/../../../../static/templates/'; +} + +global.make_sure_all_templates_have_been_compiled = function () { + var dir = template_dir(); + var fns = fs.readdirSync(dir).filter(function (fn) { + return (/\.handlebars/).test(fn); + }); + + _.each(fns, function (fn) { + var name = fn.split('.')[0]; + if (!Handlebars.templates[name]) { + throw "The file " + fn + " has no test coverage."; + } + }); +}; + global.use_template = function (name) { if (Handlebars.templates === undefined) { Handlebars.templates = {}; } - var template_dir = __dirname+'/../../../../static/templates/'; - var data = fs.readFileSync(template_dir + name + '.handlebars').toString(); + var data = fs.readFileSync(template_dir() + name + '.handlebars').toString(); Handlebars.templates[name] = Handlebars.compile(data); }; diff --git a/zerver/tests/frontend/node/templates.js b/zerver/tests/frontend/node/templates.js index 8226df349b..403f5e2ed5 100644 --- a/zerver/tests/frontend/node/templates.js +++ b/zerver/tests/frontend/node/templates.js @@ -545,7 +545,8 @@ function render(template_name, args) { 'tutorial_reply', 'tutorial_stream', 'tutorial_subject', - 'tutorial_title' + 'tutorial_title', + 'tutorial_welcome' ]; var html = ''; _.each(tutorials, function (tutorial) { @@ -604,3 +605,7 @@ function render(template_name, args) { assert.equal(a.text().trim(), 'Narrow to private messages with Hamlet'); }()); +// By the end of this test, we should have compiled all our templates. Ideally, +// we will also have exercised them to some degree, but that's a little trickier +// to enforce. +global.make_sure_all_templates_have_been_compiled();