balena-supervisor/test/08-blink.spec.coffee
Pablo Carranza Velez 652b596c80 Add some more unit tests to the multicontainer supervisor
We add a bunch of additional unit tests, and also a coverage report using istanbul.

The tests are not meant to cover everything, but they're a first attempt at having *some* unit testing
on the supervisor. There's much to improve but hopefully it helps catch obvious errors.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2018-04-30 19:39:01 -07:00

22 lines
671 B
CoffeeScript

Promise = require 'bluebird'
constants = require '../src/lib/constants'
fs = Promise.promisifyAll(require('fs'))
blink = require('../src/lib/blink')
m = require 'mochainon'
{ expect } = m.chai
describe 'blink', ->
it 'is a blink function', ->
expect(blink).to.be.a('function')
it 'has a pattern property with start and stop functions', ->
expect(blink.pattern.start).to.be.a('function')
expect(blink.pattern.stop).to.be.a('function')
it 'writes to a file that represents the LED, and writes a 0 at the end to turn the LED off', ->
blink(1)
.then ->
fs.readFileAsync(constants.ledFile)
.then (contents) ->
expect(contents.toString()).to.equal('0')