triggers-service
Version:
Service to list and activate Octoblu triggers
56 lines (42 loc) • 1.35 kB
text/coffeescript
http = require 'http'
request = require 'request'
shmock = require 'shmock'
Server = require '../../src/server'
fakeFlow = require './fake-flow.json'
describe 'GET /mytriggers', ->
beforeEach ->
= shmock 0xf00d
afterEach (done) ->
.close => done()
beforeEach (done) ->
meshbluConfig =
server: 'localhost'
port: 0xf00d
serverOptions =
port: undefined,
disableLogging: true
meshbluConfig: meshbluConfig
= new Server serverOptions
.run =>
= .address().port
done()
afterEach (done) ->
.stop => done()
beforeEach (done) ->
auth =
username: 'ai-turns-hostile'
password: 'team-token'
options =
auth: auth
json: true
.get('/v2/whoami')
.reply 200, uuid: 'ai-turns-hostile', token: 'team-token'
= .get('/devices')
.query(type:'octoblu:flow', owner:'ai-turns-hostile')
.reply 200, devices: [fakeFlow]
request.get "http://localhost:#{@serverPort}/mytriggers", options, (error, , ) =>
done error
it 'should return the triggers', ->
expect(.statusCode).to.equal 200
expect(.isDone).to.be.true
expect([0]).to.contain id: '562f4090-9ed8-11e5-bf39-09fc31cb0cf0'