Skip to content

Commit

Permalink
Update module registration for latest Cylon changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stewart committed Nov 4, 2014
1 parent 8bc3aa0 commit 91c1026
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
13 changes: 3 additions & 10 deletions lib/cylon-crazyflie.js
Expand Up @@ -8,25 +8,18 @@

"use strict";

var Cylon = require('cylon');

var Adaptor = require('./adaptor'),
Driver = require('./driver');

module.exports = {
adaptors: ['crazyflie'],
drivers: ['crazyflie'],

adaptor: function(opts) {
return new Adaptor(opts);
},

driver: function(opts) {
return new Driver(opts);
},

register: function(robot) {
Cylon.Logger.info("Registering Crazyflie adaptor for " + robot.name);
robot.registerAdaptor('cylon-crazyflie', 'crazyflie');

Cylon.Logger.info("Registering Crazyflie driver for " + robot.name);
robot.registerDriver('cylon-crazyflie', 'crazyflie');
}
};
24 changes: 7 additions & 17 deletions test/specs/cylon-crazyflie.spec.js
Expand Up @@ -6,27 +6,17 @@ var Adaptor = source('adaptor'),
Driver = source('driver');

describe("Cylon.Crazyflie", function() {
describe("#register", function() {
var bot, adaptor, driver;

beforeEach(function() {
bot = { registerAdaptor: spy(), registerDriver: spy() };

adaptor = bot.registerAdaptor;
driver = bot.registerDriver;

module.register(bot);
});

it("registers the 'crazyflie' adaptor with the robot", function() {
expect(adaptor).to.be.calledWith('cylon-crazyflie', 'crazyflie');
describe("#adaptors", function() {
it('is an array of supplied adaptors', function() {
expect(module.adaptors).to.be.eql(['crazyflie']);
});
});

it("registers the 'crazyflie' driver with the robot", function() {
expect(driver).to.be.calledWith('cylon-crazyflie', 'crazyflie');
describe("#drivers", function() {
it('is an array of supplied drivers', function() {
expect(module.drivers).to.be.eql(['crazyflie']);
});
});

describe("#adaptor", function() {
it("returns a new instance of the Crazyflie adaptor", function() {
expect(module.adaptor()).to.be.an.instanceOf(Adaptor);
Expand Down

0 comments on commit 91c1026

Please sign in to comment.