Clean up specs for JSHint
This commit is contained in:
parent
7f761c7268
commit
e2bec78de7
|
@ -1,9 +1,7 @@
|
|||
/* jshint expr:true */
|
||||
"use strict";
|
||||
|
||||
var Adaptor = source("adaptor"),
|
||||
Logger = source("logger"),
|
||||
Utils = source("utils");
|
||||
var Adaptor = source("adaptor");
|
||||
|
||||
describe("Adaptor", function() {
|
||||
var adaptor = new Adaptor({ name: "adaptor" });
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
/* jshint expr:true */
|
||||
"use strict";
|
||||
|
||||
var express = require("express"),
|
||||
https = require("https"),
|
||||
fs = require("fs"),
|
||||
var https = require("https"),
|
||||
path = require("path");
|
||||
|
||||
var API = source("api"),
|
||||
Utils = source("utils"),
|
||||
Logger = source("logger");
|
||||
|
||||
var MockRequest = require("../support/mock_request"),
|
||||
|
@ -32,11 +29,9 @@ describe("API", function() {
|
|||
|
||||
it("sets @express to an Express instance", function() {
|
||||
expect(api.express.listen).to.be.a("function");
|
||||
})
|
||||
});
|
||||
|
||||
it("sets default values", function() {
|
||||
var sslPath = path.normalize(__dirname + "/../../lib/api/ssl/");
|
||||
|
||||
expect(api.host).to.be.eql("127.0.0.1");
|
||||
expect(api.port).to.be.eql("3000");
|
||||
});
|
||||
|
@ -104,7 +99,7 @@ describe("API", function() {
|
|||
});
|
||||
|
||||
it("logs that the API is insecure", function() {
|
||||
expect(Logger.warn).to.be.calledWithMatch("insecure connection")
|
||||
expect(Logger.warn).to.be.calledWithMatch("insecure connection");
|
||||
});
|
||||
|
||||
it("sets @server to @express", function() {
|
||||
|
@ -116,7 +111,7 @@ describe("API", function() {
|
|||
describe("#setupAuth", function() {
|
||||
context("when auth.type is basic", function() {
|
||||
beforeEach(function() {
|
||||
api.auth = { type: "basic", user: "user", pass: "pass" }
|
||||
api.auth = { type: "basic", user: "user", pass: "pass" };
|
||||
});
|
||||
|
||||
it("returns a basic auth middleware function", function() {
|
||||
|
@ -125,7 +120,7 @@ describe("API", function() {
|
|||
res = new MockResponse(),
|
||||
next = spy();
|
||||
|
||||
var auth = "Basic " + new Buffer("user:pass").toString("base64")
|
||||
var auth = "Basic " + new Buffer("user:pass").toString("base64");
|
||||
|
||||
req.headers.authorization = auth;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* jshint expr:true */
|
||||
"use strict"
|
||||
"use strict";
|
||||
|
||||
var basic = source("api/auth/basic");
|
||||
|
||||
|
@ -65,7 +65,7 @@ describe("Basic Auth", function() {
|
|||
|
||||
it("doesn't modify the response", function() {
|
||||
expect(res.end).to.not.be.called;
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
context("if the user/pass don't match", function() {
|
||||
|
@ -91,7 +91,7 @@ describe("Basic Auth", function() {
|
|||
|
||||
it("doesn't modify the response", function() {
|
||||
expect(res.end).to.not.be.called;
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
context("if there are no authorization headers", function() {
|
||||
|
|
|
@ -10,7 +10,7 @@ describe("Basestar", function() {
|
|||
describe("#proxyMethods", function() {
|
||||
var methods = ["asString", "toString", "returnString"];
|
||||
|
||||
var ProxyClass = function ProxyClass() {}
|
||||
var ProxyClass = function ProxyClass() {};
|
||||
|
||||
ProxyClass.prototype.asString = function() {
|
||||
return "[object ProxyClass]";
|
||||
|
@ -25,27 +25,27 @@ describe("Basestar", function() {
|
|||
};
|
||||
|
||||
var TestClass = function TestClass() {
|
||||
this.testInstance = new ProxyClass;
|
||||
this.testInstance = new ProxyClass();
|
||||
this.proxyMethods(methods, this.testInstance, this, true);
|
||||
}
|
||||
};
|
||||
|
||||
Utils.subclass(TestClass, Basestar);
|
||||
|
||||
it("can alias methods", function() {
|
||||
var testclass = new TestClass;
|
||||
expect(testclass.asString).to.be.a("function")
|
||||
var testclass = new TestClass();
|
||||
expect(testclass.asString).to.be.a("function");
|
||||
expect(testclass.asString()).to.be.equal("[object ProxyClass]");
|
||||
});
|
||||
|
||||
it("can alias existing methods if forced to", function() {
|
||||
var testclass = new TestClass;
|
||||
expect(testclass.toString).to.be.a("function")
|
||||
var testclass = new TestClass();
|
||||
expect(testclass.toString).to.be.a("function");
|
||||
expect(testclass.toString()).to.be.equal("[object ProxyClass]");
|
||||
});
|
||||
|
||||
it("can alias methods with arguments", function() {
|
||||
var testclass = new TestClass;
|
||||
expect(testclass.returnString).to.be.a("function")
|
||||
var testclass = new TestClass();
|
||||
expect(testclass.returnString).to.be.a("function");
|
||||
expect(testclass.returnString("testString")).to.be.equal("testString");
|
||||
});
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ describe("Basestar", function() {
|
|||
target: this.proxy,
|
||||
sendUpdate: update
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Utils.subclass(ProxyClass, Basestar);
|
||||
Utils.subclass(EmitterClass, Basestar);
|
||||
|
@ -76,7 +76,7 @@ describe("Basestar", function() {
|
|||
proxy.on("testevent", eventSpy);
|
||||
testclass.emit("testevent", "data");
|
||||
|
||||
assert(eventSpy.calledWith("data"))
|
||||
expect(eventSpy).to.be.calledWith("data");
|
||||
});
|
||||
|
||||
it("emits an 'update' event if told to", function() {
|
||||
|
@ -87,7 +87,7 @@ describe("Basestar", function() {
|
|||
proxy.on("update", updateSpy);
|
||||
testclass.emit("testevent", "data");
|
||||
|
||||
assert(updateSpy.calledWith("testevent", "data"));
|
||||
expect(updateSpy).to.be.calledWith("testevent", "data");
|
||||
});
|
||||
|
||||
it("does not emit an 'update' event by default", function() {
|
||||
|
@ -98,7 +98,7 @@ describe("Basestar", function() {
|
|||
proxy.on("update", updateSpy);
|
||||
testclass.emit("testevent", "data");
|
||||
|
||||
assert(!updateSpy.calledWith("testevent", "data"));
|
||||
expect(updateSpy).to.not.be.calledWith("testevent", "data");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -117,7 +117,7 @@ describe("Basestar", function() {
|
|||
basestar.defineAdaptorEvent({ eventName: "testevent" });
|
||||
|
||||
basestar.connector.emit("testevent", "data");
|
||||
assert(eventSpy.calledWith("data"));
|
||||
expect(eventSpy).to.be.calledWith("data");
|
||||
});
|
||||
|
||||
context("when given a string", function() {
|
||||
|
@ -128,7 +128,7 @@ describe("Basestar", function() {
|
|||
basestar.defineAdaptorEvent("testevent");
|
||||
|
||||
basestar.connector.emit("testevent", "data");
|
||||
assert(eventSpy.calledWith("data"));
|
||||
expect(eventSpy).to.be.calledWith("data");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -148,7 +148,7 @@ describe("Basestar", function() {
|
|||
basestar.defineDriverEvent({ eventName: "testevent" });
|
||||
|
||||
basestar.connection.emit("testevent", "data");
|
||||
assert(eventSpy.calledWith("data"));
|
||||
expect(eventSpy).to.be.calledWith("data");
|
||||
});
|
||||
|
||||
context("when given a string", function() {
|
||||
|
@ -159,7 +159,7 @@ describe("Basestar", function() {
|
|||
basestar.defineDriverEvent("testevent");
|
||||
|
||||
basestar.connection.emit("testevent", "data");
|
||||
assert(eventSpy.calledWith("data"));
|
||||
expect(eventSpy).to.be.calledWith("data");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"use strict";
|
||||
|
||||
var Loopback = source("test/loopback"),
|
||||
Connection = source("connection");
|
||||
connection = source("connection");
|
||||
|
||||
describe("Connection", function() {
|
||||
it("returns a Adaptor instance", function() {
|
||||
var conn = Connection({
|
||||
var conn = connection({
|
||||
name: "test",
|
||||
adaptor: "loopback"
|
||||
});
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
"use strict";
|
||||
|
||||
var Cylon = source("cylon"),
|
||||
Robot = source("robot"),
|
||||
Utils = source("utils");
|
||||
Robot = source("robot");
|
||||
|
||||
var API = source("api"),
|
||||
Logger = source("logger"),
|
||||
|
@ -47,16 +46,16 @@ describe("Cylon", function() {
|
|||
var opts = { name: "Ultron" };
|
||||
var robot = Cylon.robot(opts);
|
||||
|
||||
expect(robot.toString()).to.be.eql("[Robot name='Ultron']")
|
||||
expect(robot.toString()).to.be.eql("[Robot name='Ultron']");
|
||||
expect(Cylon.robots["Ultron"]).to.be.eql(robot);
|
||||
});
|
||||
|
||||
it("avoids duplicating names", function() {
|
||||
Cylon.robot({ name: "Ultron" })
|
||||
Cylon.robot({ name: "Ultron" })
|
||||
Cylon.robot({ name: "Ultron" });
|
||||
Cylon.robot({ name: "Ultron" });
|
||||
|
||||
var bots = Object.keys(Cylon.robots);
|
||||
expect(bots).to.be.eql(["Ultron", "Ultron-1"])
|
||||
expect(bots).to.be.eql(["Ultron", "Ultron-1"]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -78,7 +77,7 @@ describe("Cylon", function() {
|
|||
Cylon.config({ api: { port: "1234" }});
|
||||
Cylon.api();
|
||||
expect(Cylon.api_instance.port).to.be.eql("1234");
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("#start", function() {
|
||||
|
@ -142,7 +141,7 @@ describe("Cylon", function() {
|
|||
|
||||
Cylon.config({ a: 1, logging: { logger: false } });
|
||||
expect(Logger.setup).to.be.called;
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("#halt", function() {
|
||||
|
@ -181,6 +180,6 @@ describe("Cylon", function() {
|
|||
|
||||
it("contains an array of MCP commands", function() {
|
||||
expect(json.commands).to.be.eql(["echo"]);
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"use strict";
|
||||
|
||||
var Ping = source("test/ping"),
|
||||
Device = source("device");
|
||||
device = source("device");
|
||||
|
||||
describe("Device", function() {
|
||||
it("returns a Driver instance", function() {
|
||||
var driver = Device({
|
||||
var driver = device({
|
||||
name: "test",
|
||||
driver: "ping"
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ var DigitalPin = source("io/digital-pin"),
|
|||
Utils = source("utils");
|
||||
|
||||
describe("Cylon.IO.DigitalPin", function() {
|
||||
var pin = new DigitalPin({ pin: "4", mode: "w" })
|
||||
var pin = new DigitalPin({ pin: "4", mode: "w" });
|
||||
|
||||
describe("constructor", function() {
|
||||
it("sets @pinNum to the pin number passed in opts", function() {
|
||||
|
@ -185,8 +185,6 @@ describe("Cylon.IO.DigitalPin", function() {
|
|||
});
|
||||
|
||||
describe("#digitalRead", function() {
|
||||
var path = "/sys/class/gpio/gpio4/value";
|
||||
|
||||
beforeEach(function() {
|
||||
this.clock = sinon.useFakeTimers();
|
||||
});
|
||||
|
@ -295,7 +293,7 @@ describe("Cylon.IO.DigitalPin", function() {
|
|||
describe("#toggle", function() {
|
||||
context("when @status is 'high'", function() {
|
||||
beforeEach(function() {
|
||||
stub(pin, "setLow")
|
||||
stub(pin, "setLow");
|
||||
pin.status = "high";
|
||||
});
|
||||
|
||||
|
@ -311,7 +309,7 @@ describe("Cylon.IO.DigitalPin", function() {
|
|||
|
||||
context("when @status is 'low'", function() {
|
||||
beforeEach(function() {
|
||||
stub(pin, "setHigh")
|
||||
stub(pin, "setHigh");
|
||||
pin.status = "low";
|
||||
});
|
||||
|
||||
|
@ -342,8 +340,8 @@ describe("Cylon.IO.DigitalPin", function() {
|
|||
|
||||
it("writes the pin number to the GPIO export path", function() {
|
||||
pin._createGPIOPin();
|
||||
expect(fs.writeFile).to.be.calledWith(path, "4")
|
||||
})
|
||||
expect(fs.writeFile).to.be.calledWith(path, "4");
|
||||
});
|
||||
|
||||
it("calls #_openPin", function() {
|
||||
pin._createGPIOPin();
|
||||
|
@ -367,7 +365,7 @@ describe("Cylon.IO.DigitalPin", function() {
|
|||
expect(pin.emit).to.be.calledWith("error");
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe("#_openPin", function() {
|
||||
beforeEach(function() {
|
||||
|
@ -419,7 +417,7 @@ describe("Cylon.IO.DigitalPin", function() {
|
|||
|
||||
it("emits a 'close' event with the pin number", function() {
|
||||
expect(pin.emit).to.be.calledWith("close", "4");
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
/* jshint expr:true */
|
||||
"use strict";
|
||||
|
||||
var EventEmitter = require("events").EventEmitter;
|
||||
|
||||
var Driver = source("driver"),
|
||||
Logger = source("logger"),
|
||||
Utils = source("utils");
|
||||
var Driver = source("driver");
|
||||
|
||||
describe("Driver", function() {
|
||||
var connection, device, driver;
|
||||
var connection, driver;
|
||||
|
||||
beforeEach(function() {
|
||||
connection = {
|
||||
|
|
|
@ -9,17 +9,17 @@ describe("IOUtils", function() {
|
|||
|
||||
it("calculates values for PWM", function() {
|
||||
var value = fn(0.5, 2000, null, null);
|
||||
expect(value).to.be.eql({ period: 500000, duty: 250000 })
|
||||
expect(value).to.be.eql({ period: 500000, duty: 250000 });
|
||||
});
|
||||
|
||||
it("calculates values for servos", function() {
|
||||
var value = fn(0.5, 50, { min: 500, max: 2400 }, "high");
|
||||
expect(value).to.be.eql({ duty: 1450000, period: 20000000 })
|
||||
expect(value).to.be.eql({ duty: 1450000, period: 20000000 });
|
||||
});
|
||||
|
||||
it("calculates values for different polarities", function() {
|
||||
var value = fn(0.5, 50, { min: 500, max: 2400 }, "low");
|
||||
expect(value).to.be.eql({ duty: 18550000, period: 20000000 })
|
||||
expect(value).to.be.eql({ duty: 18550000, period: 20000000 });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
"use strict";
|
||||
|
||||
var Logger = source("logger"),
|
||||
Config = source("config"),
|
||||
Utils = source("utils");
|
||||
Config = source("config");
|
||||
|
||||
describe("Logger", function() {
|
||||
afterEach(function() {
|
||||
|
@ -114,12 +113,12 @@ describe("Logger", function() {
|
|||
Config.logging = {
|
||||
logger: logger,
|
||||
level: "warn"
|
||||
}
|
||||
};
|
||||
|
||||
Logger.setup();
|
||||
});
|
||||
|
||||
it("prevents logging of anything below the specified log level", function() {
|
||||
it("prevents logging below the specified level", function() {
|
||||
Logger.debug("debug message");
|
||||
Logger.info("info message");
|
||||
|
||||
|
@ -127,7 +126,7 @@ describe("Logger", function() {
|
|||
expect(logger.info).to.not.be.called;
|
||||
});
|
||||
|
||||
it("still logs anything equal or greater than the specified log level", function() {
|
||||
it("still logs levels equal/greater than the specified level", function() {
|
||||
Logger.warn("warn message");
|
||||
Logger.error("error message");
|
||||
Logger.fatal("fatal message");
|
||||
|
@ -146,6 +145,6 @@ describe("Logger", function() {
|
|||
|
||||
expect(logger.debug).to.not.be.called;
|
||||
expect(logger.info).to.be.calledWith("info message");
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ var Registry = source("registry");
|
|||
|
||||
var path = "./../spec/support/mock_module.js";
|
||||
|
||||
var module = require("./../support/mock_module.js")
|
||||
var mod = require("./../support/mock_module.js");
|
||||
|
||||
describe("Registry", function() {
|
||||
var original;
|
||||
|
@ -17,7 +17,7 @@ describe("Registry", function() {
|
|||
|
||||
afterEach(function() {
|
||||
Registry.data = original;
|
||||
})
|
||||
});
|
||||
|
||||
describe("#register", function() {
|
||||
it("adds the supplied module to the Registry", function() {
|
||||
|
@ -27,7 +27,7 @@ describe("Registry", function() {
|
|||
|
||||
expect(Registry.data).to.be.eql({
|
||||
"./../spec/support/mock_module.js": {
|
||||
module: module,
|
||||
module: mod,
|
||||
drivers: ["test-driver"],
|
||||
adaptors: ["test-adaptor"],
|
||||
dependencies: []
|
||||
|
@ -38,21 +38,21 @@ describe("Registry", function() {
|
|||
|
||||
describe("#findByAdaptor", function() {
|
||||
beforeEach(function() {
|
||||
Registry.register(path)
|
||||
Registry.register(path);
|
||||
});
|
||||
|
||||
it("finds the appropriate module containing the adaptor", function() {
|
||||
expect(Registry.findByAdaptor("test-adaptor")).to.be.eql(module);
|
||||
expect(Registry.findByAdaptor("test-adaptor")).to.be.eql(mod);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#findByDriver", function() {
|
||||
beforeEach(function() {
|
||||
Registry.register(path)
|
||||
Registry.register(path);
|
||||
});
|
||||
|
||||
it("finds the appropriate module containing the driver", function() {
|
||||
expect(Registry.findByDriver("test-driver")).to.be.eql(module);
|
||||
expect(Registry.findByDriver("test-driver")).to.be.eql(mod);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
var Driver = source("driver"),
|
||||
Adaptor = source("adaptor"),
|
||||
Robot = source("robot"),
|
||||
Utils = source("utils");
|
||||
Robot = source("robot");
|
||||
|
||||
describe("Robot", function() {
|
||||
var work, extraFunction, robot;
|
||||
|
@ -28,7 +27,7 @@ describe("Robot", function() {
|
|||
describe("name", function() {
|
||||
context("if provided", function() {
|
||||
it("is set to the passed value", function() {
|
||||
expect(robot.name).to.be.eql("Robby")
|
||||
expect(robot.name).to.be.eql("Robby");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -91,7 +90,7 @@ describe("Robot", function() {
|
|||
robot = new Robot({
|
||||
name: "NewBot",
|
||||
otherThings: { more: "details" },
|
||||
sayHello: function() { return "Hello!" }
|
||||
sayHello: function() { return "Hello!"; }
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -107,12 +106,12 @@ describe("Robot", function() {
|
|||
robot = new Robot({
|
||||
name: "NewBot",
|
||||
|
||||
sayHello: function() { return this.name + " says hello" },
|
||||
sayHello: function() { return this.name + " says hello"; },
|
||||
|
||||
commands: function() {
|
||||
return {
|
||||
say_hello: this.sayHello
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -125,20 +124,25 @@ describe("Robot", function() {
|
|||
var fn;
|
||||
beforeEach(function() {
|
||||
fn = function() {
|
||||
new Robot({
|
||||
var bot = new Robot({
|
||||
name: "NewBot",
|
||||
|
||||
commands: function() {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return bot;
|
||||
};
|
||||
});
|
||||
|
||||
it("throws an error", function() {
|
||||
expect(fn).to.throw(Error, "#commands function must return an object");
|
||||
expect(fn).to.throw(
|
||||
Error,
|
||||
"#commands function must return an object"
|
||||
);
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
context("if a commands object is provided", function() {
|
||||
|
@ -148,7 +152,7 @@ describe("Robot", function() {
|
|||
robot = new Robot({
|
||||
name: "NewBot",
|
||||
|
||||
sayHello: function() { return this.name + " says hello" },
|
||||
sayHello: function() { return this.name + " says hello"; },
|
||||
|
||||
commands: {
|
||||
say_hello: function() {}
|
||||
|
@ -173,19 +177,23 @@ describe("Robot", function() {
|
|||
},
|
||||
|
||||
start: "start"
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it("passes them through if they don't conflict with built-ins", function() {
|
||||
context("if they don't conflict with built-ins", function() {
|
||||
it("passes them through", function() {
|
||||
expect(robot.hiThere).to.be.eql("hi there");
|
||||
expect(robot.sayHi()).to.be.eql("hi");
|
||||
});
|
||||
});
|
||||
|
||||
it("doesn't work if they conflict with built-in properties", function() {
|
||||
context("if they do conflict with built-ins", function() {
|
||||
it("doesn't pass them through", function() {
|
||||
expect(robot.start).to.be.a("function");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("all work and no play", function() {
|
||||
var play = spy();
|
||||
|
@ -196,7 +204,7 @@ describe("Robot", function() {
|
|||
|
||||
it("makes Jack a dull boy", function() {
|
||||
expect(playBot.work).to.be.eql(play);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
describe("#toJSON", function() {
|
||||
|
@ -245,17 +253,20 @@ describe("Robot", function() {
|
|||
expect(bot.connections.loopback).to.be.eql(undefined);
|
||||
bot.connection("loopback", opts);
|
||||
expect(bot.connections.loopback).to.be.an.instanceOf(Adaptor);
|
||||
})
|
||||
});
|
||||
|
||||
it("sets @robot on the Connection to be the Robot initializing it", function() {
|
||||
it("sets connection.robot on to the Robot initializing it", function() {
|
||||
bot.connection("loopback", opts);
|
||||
expect(bot.connections.loopback.robot).to.be.eql(bot);
|
||||
})
|
||||
});
|
||||
|
||||
it("avoids name collisions", function() {
|
||||
bot.connection("loopback", opts);
|
||||
bot.connection("loopback", opts);
|
||||
expect(Object.keys(bot.connections)).to.be.eql(["loopback", "loopback-1"]);
|
||||
|
||||
var conns = Object.keys(bot.connections);
|
||||
|
||||
expect(conns).to.be.eql(["loopback", "loopback-1"]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -282,8 +293,8 @@ describe("Robot", function() {
|
|||
});
|
||||
|
||||
context("when passed an array of connection objects", function() {
|
||||
it("instantiates a new connection with each of the provided objects", function() {
|
||||
var connections = [{ name: "loopback", adaptor: "loopback" }]
|
||||
it("creates new connections with each of the ones provided", function() {
|
||||
var connections = [{ name: "loopback", adaptor: "loopback" }];
|
||||
bot.initConnections({ connections: connections });
|
||||
expect(bot.connections["loopback"]).to.be.instanceOf(Adaptor);
|
||||
});
|
||||
|
@ -316,12 +327,12 @@ describe("Robot", function() {
|
|||
expect(bot.devices.ping).to.be.eql(undefined);
|
||||
bot.device("ping", opts);
|
||||
expect(bot.devices.ping).to.be.an.instanceOf(Driver);
|
||||
})
|
||||
});
|
||||
|
||||
it("sets @robot on the Device to be the Robot initializing it", function() {
|
||||
bot.device("ping", opts);
|
||||
expect(bot.devices.ping.robot).to.be.eql(bot);
|
||||
})
|
||||
});
|
||||
|
||||
it("avoids name collisions", function() {
|
||||
bot.device("ping", opts);
|
||||
|
@ -357,8 +368,8 @@ describe("Robot", function() {
|
|||
});
|
||||
|
||||
context("when passed an array of device objects", function() {
|
||||
it("instantiates a new driver with each of the provided objects", function() {
|
||||
var devices = [{ name: "ping", driver: "ping" }]
|
||||
it("instantiates new drivers with provided objects", function() {
|
||||
var devices = [{ name: "ping", driver: "ping" }];
|
||||
bot.initDevices({ devices: devices});
|
||||
|
||||
expect(bot.devices["ping"]).to.be.instanceOf(Driver);
|
||||
|
@ -406,7 +417,7 @@ describe("Robot", function() {
|
|||
});
|
||||
|
||||
it("emits the 'ready' event", function() {
|
||||
expect(robot.emit).to.be.calledWith("ready", robot)
|
||||
expect(robot.emit).to.be.calledWith("ready", robot);
|
||||
});
|
||||
|
||||
it("returns the robot", function() {
|
||||
|
|
|
@ -46,13 +46,17 @@ describe("Utils", function() {
|
|||
expect((0.5).toScale(0, 10)).to.be.eql(5);
|
||||
});
|
||||
|
||||
it("bottom of scale should be returned when value goes below it", function() {
|
||||
context("when value goes below bottom of scale", function() {
|
||||
it("returns the bottom of the scale", function() {
|
||||
expect((-5).toScale(0, 10)).to.be.eql(0);
|
||||
});
|
||||
});
|
||||
|
||||
it("top of scale should be returned when value goes above it", function() {
|
||||
context("when value goes above top of scale", function() {
|
||||
it("returns the top of the scale", function() {
|
||||
expect((15).toScale(0, 10)).to.be.eql(10);
|
||||
});
|
||||
});
|
||||
|
||||
it("converts to floats", function() {
|
||||
expect((0.25).toScale(0, 10)).to.be.eql(2.5);
|
||||
|
@ -92,7 +96,7 @@ describe("Utils", function() {
|
|||
this.clock.restore();
|
||||
});
|
||||
|
||||
it("sets a function to be called every time an interval passes", function() {
|
||||
it("sets a function to be called when an interval passes", function() {
|
||||
var func = spy();
|
||||
utils.every(10, func);
|
||||
this.clock.tick(25);
|
||||
|
@ -109,7 +113,7 @@ describe("Utils", function() {
|
|||
this.clock.restore();
|
||||
});
|
||||
|
||||
it("sets a function to be called after time an interval passes", function() {
|
||||
it("sets a function to be called after an interval passes", function() {
|
||||
var func = spy();
|
||||
utils.after(10, func);
|
||||
this.clock.tick(15);
|
||||
|
|
Loading…
Reference in New Issue