balena-cli/lib/helpers/helpers.spec.coffee

36 lines
882 B
CoffeeScript
Raw Normal View History

expect = require('chai').expect
2014-11-28 19:36:03 +00:00
sinon = require('sinon')
_ = require('lodash')
helpers = require('./helpers')
2014-11-28 19:36:03 +00:00
resin = require('../resin')
describe 'Helpers:', ->
2014-11-28 19:36:03 +00:00
describe '#isDeviceUUIDValid()', ->
devices = [
{ uuid: 1234 }
{ uuid: 5678 }
]
deviceGetAllStub = null
beforeEach ->
deviceGetAllStub = sinon.stub(resin.models.device, 'getAll')
deviceGetAllStub.yields(null, devices)
afterEach ->
deviceGetAllStub.restore()
it 'should return true if there is a device with that UUID', (done) ->
helpers.isDeviceUUIDValid devices[0].uuid, (error, isValid) ->
expect(error).to.not.exist
expect(isValid).to.be.true
done()
it 'should return false if there is not a device with that UUID', (done) ->
helpers.isDeviceUUIDValid 'invalidUUID', (error, isValid) ->
expect(error).to.not.exist
expect(isValid).to.be.false
done()