asjon/asjon-testing.coffee
2015-04-28 10:11:01 +02:00

25 lines
828 B
CoffeeScript

#expect = require("chai").expect
path = require("path")
Robot = require("hubot/src/robot")
TextMessage = require("hubot/src/message").TextMessage
before = (done) ->
robot = new Robot null, "mock-adapter", no, 'asjon'
robot.adapter.on 'connected', ->
# Initialize mocked environment
user = robot.brain.userForId "1", { name: 'mocha', room: '#mocha' }
adapter = robot.adapter
send = (s) -> robot.adapter.receive new TextMessage user, s
receive = (f) -> robot.adapter.on 'send', f
after = -> robot.shutdown()
clear = -> robot.adapter.removeAllListeners(); robot.httpListener = ->
# Done
done
robot: robot, user: user, send: send, receive: receive
TextMessage: TextMessage, Robot: Robot
adapter: adapter, after: after, clear: clear
robot.run()
module.exports = before