2
0
mirror of https://github.com/thumbsup/thumbsup synced 2024-11-07 15:20:26 +00:00

test(all): increase unit test coverage

This commit is contained in:
Romain 2018-06-08 23:39:09 +02:00
parent 8bbe1186c5
commit 7208642d95
2 changed files with 28 additions and 0 deletions

21
test/bin/messages.spec.js Normal file
View File

@ -0,0 +1,21 @@
const should = require('should/as-function')
const messages = require('../../bin/messages.js')
describe('messages', function () {
['SUCCESS', 'GREETING', 'SORRY'].forEach(type => {
it(`wraps ${type} messages in a box`, () => {
const success = messages[type]({})
should(success.indexOf('┌───')).above(-1)
should(success.indexOf('───┐')).above(-1)
should(success.indexOf('└───')).above(-1)
should(success.indexOf('───┘')).above(-1)
should(success.split('\n').length).above(4)
})
})
it('lists mandatory binary dependencies', () => {
const required = messages.BINARIES_REQUIRED(['bin1', 'bin2'])
should(required.indexOf('bin1\n')).above(-1)
should(required.indexOf('bin2\n')).above(-1)
})
})

View File

@ -36,6 +36,13 @@ describe('Handlebars helpers: compare', () => {
}).throw(/operator/)
})
it('throws an error if there arent enough parameters', () => {
should(() => {
const template = handlebars.compile(`{{#compare value}}TRUE{{/compare}}`)
template({value: 3})
}).throw(/needs 2 parameters/)
})
it('keeps the context when executing the block', () => {
const template = handlebars.compile(`{{#compare value '==' 3}}{{hello}}{{/compare}}`)
const res = template({value: 3, hello: 'world'})