Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"repository": "pillarjs/hbs",
"main": "lib/hbs.js",
"dependencies": {
"handlebars": "4.7.9",
"handlebars": "4.7.10",
"walk": "2.3.15"
},
"devDependencies": {
Expand Down
30 changes: 15 additions & 15 deletions test/4.x/async_helper_escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ test('async helper non-string values keep their pre-escaping text output', funct
})
})

test('async helper with non-callable toHTML is a render error, not a process crash (uncached)', function (done) {
test('async helper with non-callable toHTML is ignored (uncached)', function (done) {
var hbs = require('../../').create()
var payload = JSON.parse('{"toHTML":"x"}')
hbs.registerAsyncHelper('bad', function (_opts, cb) {
process.nextTick(function () {
cb(payload)
})
})
render(hbs, makeView('async-bad-tohtml.hbs', '{{bad}}'), function (err) {
assert.ok(err, 'expected a render error instead of an uncaught throw')
assert.ok(/is not a function/.test(err.message), err.message)
render(hbs, makeView('async-bad-tohtml.hbs', '{{bad}}'), function (err, out) {
if (err) return done(err)
assert.strictEqual(out.trim(), '[object Object]')
done()
})
})

test('async helper with non-callable toHTML is a render error, not a process crash (cached)', function (done) {
test('async helper with non-callable toHTML is ignored (cached)', function (done) {
var hbs = require('../../').create()
var payload = JSON.parse('{"toHTML":"x"}')
hbs.registerAsyncHelper('bad', function (_opts, cb) {
Expand All @@ -121,18 +121,18 @@ test('async helper with non-callable toHTML is a render error, not a process cra
})
})
var view = makeView('async-bad-tohtml-cached.hbs', '{{bad}}')
render(hbs, view, { cache: true }, function (err) {
assert.ok(err, 'expected a render error on the uncached path')
assert.ok(hbs.cache[view], 'expected first render to cache the template')
render(hbs, view, { cache: true }, function (err2) {
assert.ok(err2, 'expected a render error on the cached path')
assert.ok(/is not a function/.test(err2.message), err2.message)
render(hbs, view, { cache: true }, function (err, out) {
if (err) return done(err)
assert.strictEqual(out.trim(), '[object Object]')
render(hbs, view, { cache: true }, function (err2, out2) {
if (err2) return done(err2)
assert.strictEqual(out2.trim(), '[object Object]')
done()
})
})
})

test('async helper with non-callable toHTML is a render error, not a process crash (layout)', function (done) {
test('async helper with non-callable toHTML is ignored (layout)', function (done) {
var hbs = require('../../').create()
var payload = JSON.parse('{"toHTML":"x"}')
hbs.registerAsyncHelper('bad', function (_opts, cb) {
Expand All @@ -147,9 +147,9 @@ test('async helper with non-callable toHTML is a render error, not a process cra
views: tmpDir,
'view options': { layout: path.basename(layout, '.hbs') }
}
}, function (err) {
assert.ok(err, 'expected a render error on the layout path')
assert.ok(/is not a function/.test(err.message), err.message)
}, function (err, out) {
if (err) return done(err)
assert.strictEqual(out.trim(), '<html><body>ok[object Object]</body></html>')
done()
})
})
Expand Down
Loading