From 44364ca186f706c1a790a312bf8371880b312f5a Mon Sep 17 00:00:00 2001 From: Eric Alli Date: Sat, 13 May 2023 16:23:38 -0700 Subject: [PATCH] Fixing issue #9 with tests --- helpers/each.js | 1 + test/test.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/helpers/each.js b/helpers/each.js index 502cf94..6a350b8 100644 --- a/helpers/each.js +++ b/helpers/each.js @@ -103,6 +103,7 @@ module.exports = (handlebars) => { if (i === 0) { ret = inverse(this) + ret = [inverse(this)] } return ret.join('') diff --git a/test/test.js b/test/test.js index 030c86a..a87f53c 100644 --- a/test/test.js +++ b/test/test.js @@ -344,6 +344,14 @@ describe('Test async helpers', () => { should.equal(result, expected) }) + it('Test each helper with an empty item list', async () => { + const hbs = asyncHelpers(Handlebars) + + const items = [], + result = await hbs.compile('Devs \n{{#each items}}{{/each}}')({items}) + should.equal(result, 'Devs \n') + }) + it('check version', () => { const hbs = asyncHelpers(Handlebars) should(hbs.ASYNC_VERSION).equal(require('../package.json').version)