cylon/test/dist/specs/device.spec.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-10-25 05:25:42 +08:00
(function() {
'use strict';
2013-11-05 04:16:42 +08:00
source("device");
2013-10-25 05:25:42 +08:00
2013-11-05 04:16:42 +08:00
source("robot");
2013-10-25 05:25:42 +08:00
source("driver");
source("test/ping");
2013-10-25 05:25:42 +08:00
describe("Device", function() {
var device, driver, initDriver, robot;
2013-11-05 04:16:42 +08:00
robot = new Cylon.Robot({
2013-10-25 05:25:42 +08:00
name: 'me'
});
driver = new Cylon.Drivers.Ping({
name: 'driving',
device: {
connection: 'connect',
pin: 13
}
2013-10-25 05:25:42 +08:00
});
initDriver = sinon.stub(robot, 'initDriver').returns(driver);
2013-11-05 04:16:42 +08:00
device = new Cylon.Device({
2013-10-25 05:25:42 +08:00
name: "devisive",
driver: 'driving',
robot: robot
});
it("belongs to a robot", function() {
2013-10-25 05:25:42 +08:00
return device.robot.name.should.be.equal('me');
});
it("has a name", function() {
2013-10-25 05:25:42 +08:00
return device.name.should.be.equal('devisive');
});
it("can init a driver", function() {
return initDriver.should.be.called;
2013-10-25 05:25:42 +08:00
});
it("can start a driver", function() {
var driverStart;
driverStart = sinon.stub(driver, 'start').returns(true);
device.start();
return driverStart.should.be.called;
});
it("can stop a driver", function() {
var driverStop;
driverStop = sinon.stub(driver, 'stop').returns(true);
device.stop();
return driverStop.should.be.called;
});
it("should use default connection if none specified");
return it("should use connection if one is specified");
2013-10-25 05:25:42 +08:00
});
}).call(this);