browser-meshblu-http
Version:
Meshblu Client for the Browser
45 lines (36 loc) • 1.3 kB
text/coffeescript
{afterEach, beforeEach, describe, it} = global
{expect} = require 'chai'
shmock = require '@octoblu/shmock'
enableDestroy = require 'server-destroy'
MeshbluHttp = require '../'
describe 'Search Devices', ->
beforeEach ->
= shmock()
enableDestroy
afterEach (done) ->
.destroy done
describe 'when constructed with valid meshbluConfig', ->
beforeEach ->
meshbluConfig =
hostname: 'localhost'
port: .address().port
uuid: 'some-uuid'
token: 'some-token'
= new MeshbluHttp meshbluConfig
describe 'when the device has multiple devices', ->
beforeEach (done) ->
auth = new Buffer('some-uuid:some-token').toString('base64')
=
.post '/search/devices'
.set 'Authorization', "Basic #{auth}"
.reply 200, [
uuid: 'howdy-uuid', owner: 'hello-uuid', type: 'flow'
]
query = type: 'flow', owner: 'hello-uuid'
.search {query}, (error, ) => done error
it 'should call get device', ->
.done()
it 'should have devices', ->
expect().to.deep.equal [
uuid: 'howdy-uuid', owner: 'hello-uuid', type: 'flow'
]