2
0
mirror of https://github.com/thumbsup/thumbsup synced 2024-11-17 15:25:50 +00:00
thumbsup/test/bin/messages.spec.js
Romain ad46c8db87 chores(deps): fix build after Boxen upgrade
Boxen has a new line-wrapping behavior that doesn't use
line breaks when the content is over 80 characters.

It's simpler to reformat the message.
2020-12-30 23:55:46 +01:00

40 lines
1.2 KiB
JavaScript

const should = require('should/as-function')
const messages = require('../../bin/messages.js')
describe('messages', function () {
it('shows SUCCESS in a box', () => {
const stats = { albums: 1, photos: 1, videos: 1 }
const success = messages.SUCCESS(stats)
assertInABox(success)
})
it('shows GREETING in a box', () => {
const greeting = messages.GREETING()
assertInABox(greeting)
})
it('shows SORRY in a box', () => {
const sorry = messages.SORRY('thumbsup.log')
assertInABox(sorry)
})
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)
})
it('can print one or more problem', () => {
should(messages.PROBLEMS(1).indexOf('with 1 file.')).above(-1)
should(messages.PROBLEMS(2).indexOf('with 2 files.')).above(-1)
})
})
function assertInABox (result) {
should(result.indexOf('┌───')).above(-1)
should(result.indexOf('───┐')).above(-1)
should(result.indexOf('└───')).above(-1)
should(result.indexOf('───┘')).above(-1)
should(result.split('\n').length).above(4)
}