diff --git a/test/3.x/app.js b/test/3.x/app.js index 216cd06..d7f4501 100644 --- a/test/3.x/app.js +++ b/test/3.x/app.js @@ -11,6 +11,10 @@ var assert = require('assert'); // local var hbs = require('../../').create(); +hbs.registerHelper('make_error', function () { + throw new TypeError('oops!') +}) + hbs.registerHelper('link_to', function(context) { return "" + context.body + ""; }); @@ -139,6 +143,10 @@ before(function () { }) }) + app.get('/helper-error', function (req, res) { + res.render('error') + }) + app.get('/syntax-error', function (req, res) { res.render('syntax-error', { cache: true @@ -192,6 +200,14 @@ test('partials', function(done) { .end(done) }); +test('helper error', function (done) { + request(app) + .get('/helper-error') + .expect(500) + .expect(shouldHaveFirstLineEqual('TypeError: ' + path.join(__dirname, 'views', 'error.hbs') + ': oops!')) + .end(done) +}) + test('html extension', function(done) { request(app) .get('/html') diff --git a/test/3.x/views/error.hbs b/test/3.x/views/error.hbs new file mode 100644 index 0000000..9f717eb --- /dev/null +++ b/test/3.x/views/error.hbs @@ -0,0 +1 @@ +running {{{make_error}}} diff --git a/test/4.x/app.js b/test/4.x/app.js index df689ed..cbec923 100644 --- a/test/4.x/app.js +++ b/test/4.x/app.js @@ -11,6 +11,10 @@ var assert = require('assert'); // local var hbs = require('../../').create(); +hbs.registerHelper('make_error', function () { + throw new TypeError('oops!') +}) + hbs.registerHelper('link_to', function(context) { return "" + context.body + ""; }); @@ -138,6 +142,10 @@ before(function () { }) }) + app.get('/helper-error', function (req, res) { + res.render('error') + }) + app.get('/syntax-error', function (req, res) { res.render('syntax-error', { cache: true @@ -199,6 +207,14 @@ test('index', function(done) { .end(done) }); +test('helper error', function (done) { + request(app) + .get('/helper-error') + .expect(500) + .expect(shouldHaveFirstLineEqual('TypeError: ' + path.join(__dirname, 'views', 'error.hbs') + ': oops!')) + .end(done) +}) + test('partials', function(done) { request(app) .get('/partials') diff --git a/test/4.x/views/error.hbs b/test/4.x/views/error.hbs new file mode 100644 index 0000000..9f717eb --- /dev/null +++ b/test/4.x/views/error.hbs @@ -0,0 +1 @@ +running {{{make_error}}}