browser-meshblu-http
Version:
Meshblu Client for the Browser
63 lines (49 loc) • 1.58 kB
text/coffeescript
shmock = require '@octoblu/shmock'
MeshbluHttp = require '../'
describe 'Whoami', ->
beforeEach ->
= shmock 0xd00d
afterEach (done) ->
.close => done()
describe 'when constructed with valid meshbluConfig', ->
beforeEach ->
meshbluConfig =
hostname: 'localhost'
port: 0xd00d
uuid: 'some-uuid'
token: 'some-token'
= new MeshbluHttp meshbluConfig
describe 'when the device has devices', ->
beforeEach (done) ->
auth = new Buffer('some-uuid:some-token').toString('base64')
=
.get '/v2/whoami'
.set 'Authorization', "Basic #{auth}"
.reply 200,
uuid: 'some-uuid',
devices: [
{uuid:'cheers-uuid'}
]
.whoami (error, ) => done error
it 'should call get device', ->
.done()
it 'should device', ->
device =
uuid: 'some-uuid',
devices: [
{uuid:'cheers-uuid'}
]
expect().to.deep.equal device
describe 'when constructed with a url that goes nowhere', ->
beforeEach ->
meshbluConfig =
hostname: 'localhost'
port: 0xd00d
uuid: 'some-uuid'
token: 'some-token'
= new MeshbluHttp meshbluConfig
describe 'when whoami is called', ->
beforeEach (done) ->
.whoami () => done()
it "should yield an error instead of blowing up randomly someplace in the code we can't catch", ->
expect().to.exist