cylon/test/specs/driver.spec.js

56 lines
1.7 KiB
JavaScript
Raw Normal View History

(function() {
'use strict';
2013-12-19 05:02:18 +08:00
var EventEmitter;
source("driver");
2013-12-19 05:02:18 +08:00
EventEmitter = require('events').EventEmitter;
describe("Driver", function() {
2013-12-19 05:02:18 +08:00
var device, driver;
device = new EventEmitter;
device.connection = 'connect';
driver = new Cylon.Driver({
2013-12-19 05:02:18 +08:00
name: 'TestDriver',
device: device
});
it("provides a 'start' method that accepts a callback", function() {
var spy;
expect(driver.start).to.be.a('function');
spy = sinon.spy();
driver.start(function() {
return spy();
});
return spy.should.have.been.called;
});
it("tells the device to emit the 'start' event when started", function() {
var spy;
spy = sinon.spy();
driver.device.on('start', function() {
return spy();
});
driver.start(function() {});
return spy.should.have.been.called;
});
it("provides a 'stop' method", function() {
return expect(driver.stop).to.be.a('function');
});
it("provides a default empty array of commands", function() {
return expect(driver.commands()).to.be.eql([]);
});
it("saves the provided name in the @name variable", function() {
return expect(driver.name).to.be.eql("TestDriver");
});
it("saves the provided device in the @device variable", function() {
return expect(driver.device).to.be.eql(device);
});
it("saves the provided device connection in the @device variable", function() {
return expect(driver.connection).to.be.eql('connect');
});
return it("contains a reference to itself in the @self variable", function() {
return expect(driver.self).to.be.eql(driver);
});
});
}).call(this);