Add support for work to be triggered via an event

This commit is contained in:
Andrew Stewart 2014-09-08 12:57:56 -07:00
parent c443b486cc
commit f1544e5a8f
3 changed files with 6 additions and 5 deletions

View File

@ -21,6 +21,7 @@ var Cylon = module.exports = {
Logger: Logger,
Driver: require('./driver'),
Adaptor: require('./adaptor'),
Robot: Robot,
Utils: Utils,
IO: {

View File

@ -230,11 +230,11 @@ Robot.prototype.initDevices = function(devices) {
// Returns the result of the work
Robot.prototype.start = function() {
var begin = function(callback) {
Logger.info('Working.');
this.emit('work', this);
this.work.call(this, this);
this.running = true;
this.emit('working');
Logger.info('Working.');
callback(null, true);
}.bind(this);

View File

@ -316,8 +316,8 @@ describe("Robot", function() {
expect(robot.work).to.be.called;
});
it("emits the 'working' event", function() {
expect(robot.emit).to.be.calledWith("working")
it("emits the 'work' event", function() {
expect(robot.emit).to.be.calledWith("work")
});
});