Skip to content

Commit

Permalink
Add tests to increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nknapp committed Mar 14, 2017
1 parent aa006af commit cc0bf3e
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion test/main-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,49 @@ describe('customize-engine-handlebars', function () {
})
})

it('should throw an exception if loading an existing helpers module fails', function () {
it('should load helpers and data from a function', function () {
var hb2 = hb.merge({
handlebars: {
helpers: function () {
return {
helper1: function (value) {
return `helper1[${value}]`
}
}
},
data: function () {
return ['eins', 'zwei', 'drei', 'view'].reduce((result, key) => {
result[key] = key.split('').reverse().join('')
return result
}, {})
}
}
})
return expect(hb2.run()).to.eventually.deep.equal({
handlebars: {
'a.md': 'a.md testPartials1/eins ->snie<-',
'b.md': 'b.md testPartials1/zwei ->iewz<- helper1[->iewz<-]'
}
})
})

it('should throw an exception if loading an existing helpers-module fails', function () {
return expect(hb.merge({
handlebars: {
helpers: 'test/fixtures/helpers-error.js'
}
}).run()).to.be.rejected
})

it('should throw no exception if a helper- or preprocessor-module does not exist', function () {
return expect(hb.merge({
handlebars: {
helpers: 'test/fixtures/non-existing-helper.js',
preprocessor: 'test/fixtures/non-existing-preprocessor.js'
}
}).run()).not.to.be.rejected
})

it('should apply the partial wrapper', function () {
var hb2 = hb.merge({
handlebars: {
Expand Down

0 comments on commit cc0bf3e

Please sign in to comment.