Merge pull request #287 from hybridgroup/feature/eslint
Add ESLint for A Better Clean™
This commit is contained in:
commit
a50508e8d8
|
@ -0,0 +1,52 @@
|
||||||
|
env:
|
||||||
|
node: true
|
||||||
|
|
||||||
|
globals:
|
||||||
|
every: true
|
||||||
|
after: true
|
||||||
|
constantly: true
|
||||||
|
expect: true
|
||||||
|
source: true
|
||||||
|
stub: true
|
||||||
|
spy: true
|
||||||
|
chai: true
|
||||||
|
sinon: true
|
||||||
|
|
||||||
|
rules:
|
||||||
|
camelcase: [2, {properties: "always"}]
|
||||||
|
comma-dangle: "always-multiline"
|
||||||
|
comma-spacing: [2, {before: false, after: true}]
|
||||||
|
comma-style: [2, "last"]
|
||||||
|
handle-callback-err: [2, "^.*(e|E)rr" ]
|
||||||
|
indent: [2, 2]
|
||||||
|
key-spacing: [2, { beforeColon: false, afterColon: true }]
|
||||||
|
max-depth: [1, 3]
|
||||||
|
max-len: [1, 80, 4]
|
||||||
|
max-nested-callbacks: [1, 3]
|
||||||
|
no-cond-assign: 2
|
||||||
|
no-constant-condition: 2
|
||||||
|
no-dupe-args: 2
|
||||||
|
no-dupe-keys: 2
|
||||||
|
no-else-return: 2
|
||||||
|
no-empty: 2
|
||||||
|
no-lonely-if: 2
|
||||||
|
no-multiple-empty-lines: 2
|
||||||
|
no-nested-ternary: 2
|
||||||
|
no-reserved-keys: 2
|
||||||
|
no-self-compare: 2
|
||||||
|
no-sync: 1
|
||||||
|
no-throw-literal: 2
|
||||||
|
no-underscore-dangle: 0
|
||||||
|
quote-props: [2, "as-needed"]
|
||||||
|
quotes: [2, "double", "avoid-escape"]
|
||||||
|
radix: 2
|
||||||
|
semi-spacing: [2, {before: false, after: true}]
|
||||||
|
semi: [2, "always"]
|
||||||
|
space-after-keywords: [2, "always"]
|
||||||
|
space-before-blocks: [2, "always"]
|
||||||
|
space-before-function-paren: [1, "never"]
|
||||||
|
space-in-parens: [2, "never"]
|
||||||
|
spaced-line-comment: [1, "always"]
|
||||||
|
strict: [2, "global"]
|
||||||
|
valid-jsdoc: 2
|
||||||
|
yoda: [2, "never"]
|
38
.jshintrc
38
.jshintrc
|
@ -1,38 +0,0 @@
|
||||||
{
|
|
||||||
"node": true,
|
|
||||||
|
|
||||||
"globals": {
|
|
||||||
"every": true,
|
|
||||||
"after": true,
|
|
||||||
"constantly": true,
|
|
||||||
|
|
||||||
"it": true,
|
|
||||||
"expect": true,
|
|
||||||
"source": true,
|
|
||||||
"describe": true,
|
|
||||||
"context": true,
|
|
||||||
"beforeEach": true,
|
|
||||||
"afterEach": true,
|
|
||||||
"stub": true,
|
|
||||||
"spy": true,
|
|
||||||
"chai": true,
|
|
||||||
"sinon": true
|
|
||||||
},
|
|
||||||
|
|
||||||
"boss": true,
|
|
||||||
"curly": true,
|
|
||||||
"eqeqeq": true,
|
|
||||||
"eqnull": true,
|
|
||||||
"immed": true,
|
|
||||||
"indent": 2,
|
|
||||||
"latedef": true,
|
|
||||||
"maxlen": 80,
|
|
||||||
"newcap": true,
|
|
||||||
"noarg": true,
|
|
||||||
"nonew": true,
|
|
||||||
"quotmark": "double",
|
|
||||||
"strict": true,
|
|
||||||
"sub": true,
|
|
||||||
"undef": true,
|
|
||||||
"unused": true
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ node_js:
|
||||||
before_install:
|
before_install:
|
||||||
- "mkdir -p ~/.npm"
|
- "mkdir -p ~/.npm"
|
||||||
before_script:
|
before_script:
|
||||||
- npm install -g istanbul jshint codeclimate-test-reporter
|
- npm install -g istanbul codeclimate-test-reporter
|
||||||
script:
|
script:
|
||||||
- make ci
|
- make ci
|
||||||
- CODECLIMATE_REPO_TOKEN=d3aad610220b6eaf4f51e38393c1b62586b1d68b898b42e418d9c2a8e0a7cb0d codeclimate < coverage/lcov.info
|
- CODECLIMATE_REPO_TOKEN=d3aad610220b6eaf4f51e38393c1b62586b1d68b898b42e418d9c2a8e0a7cb0d codeclimate < coverage/lcov.info
|
||||||
|
|
3
Makefile
3
Makefile
|
@ -1,5 +1,4 @@
|
||||||
BIN := ./node_modules/.bin
|
BIN := ./node_modules/.bin
|
||||||
FILES := $(shell find lib spec/lib examples -type f -name "*.js")
|
|
||||||
TEST_FILES := spec/helper.js $(shell find spec/lib -type f -name "*.js")
|
TEST_FILES := spec/helper.js $(shell find spec/lib -type f -name "*.js")
|
||||||
|
|
||||||
VERSION := $(shell node -e "console.log(require('./package.json').version)")
|
VERSION := $(shell node -e "console.log(require('./package.json').version)")
|
||||||
|
@ -18,7 +17,7 @@ cover:
|
||||||
@istanbul cover $(BIN)/_mocha $(TEST_FILES) --report lcovonly -- -R spec
|
@istanbul cover $(BIN)/_mocha $(TEST_FILES) --report lcovonly -- -R spec
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@jshint $(FILES)
|
@eslint lib spec examples
|
||||||
|
|
||||||
ci: lint cover
|
ci: lint cover
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
rules:
|
||||||
|
camelcase: 0
|
|
@ -10,8 +10,8 @@ Cylon.api({
|
||||||
});
|
});
|
||||||
|
|
||||||
var bots = {
|
var bots = {
|
||||||
"Thelma": "/dev/rfcomm0",
|
Thelma: "/dev/rfcomm0",
|
||||||
"Louise": "/dev/rfcomm1"
|
Louise: "/dev/rfcomm1"
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.keys(bots).forEach(function(name) {
|
Object.keys(bots).forEach(function(name) {
|
||||||
|
|
|
@ -6,10 +6,10 @@ var Green = 0x0000FF,
|
||||||
Red = 0xFF0000;
|
Red = 0xFF0000;
|
||||||
|
|
||||||
var bots = {
|
var bots = {
|
||||||
"Thelma": "/dev/rfcomm0",
|
Thelma: "/dev/rfcomm0",
|
||||||
"Louise": "/dev/rfcomm1",
|
Louise: "/dev/rfcomm1",
|
||||||
"Grace": "/dev/rfcomm2",
|
Grace: "/dev/rfcomm2",
|
||||||
"Ada": "/dev/rfcomm3"
|
Ada: "/dev/rfcomm3"
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.keys(bots).forEach(function(name) {
|
Object.keys(bots).forEach(function(name) {
|
||||||
|
|
|
@ -6,10 +6,10 @@ var Green = 0x0000FF,
|
||||||
Red = 0xFF0000;
|
Red = 0xFF0000;
|
||||||
|
|
||||||
var bots = {
|
var bots = {
|
||||||
"Thelma": "/dev/rfcomm0",
|
Thelma: "/dev/rfcomm0",
|
||||||
"Louise": "/dev/rfcomm1",
|
Louise: "/dev/rfcomm1",
|
||||||
"Grace": "/dev/rfcomm2",
|
Grace: "/dev/rfcomm2",
|
||||||
"Ada": "/dev/rfcomm3"
|
Ada: "/dev/rfcomm3"
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.keys(bots).forEach(function(name) {
|
Object.keys(bots).forEach(function(name) {
|
||||||
|
|
|
@ -18,12 +18,12 @@ Cylon.robot({
|
||||||
},
|
},
|
||||||
|
|
||||||
work: function(my) {
|
work: function(my) {
|
||||||
every((1).seconds(), function(){
|
every((1).seconds(), function() {
|
||||||
console.log("Hello, human!");
|
console.log("Hello, human!");
|
||||||
console.log(my.ping.ping());
|
console.log(my.ping.ping());
|
||||||
});
|
});
|
||||||
|
|
||||||
after((5).seconds(), function(){
|
after((5).seconds(), function() {
|
||||||
console.log("I've been at your command for 5 seconds now.");
|
console.log("I've been at your command for 5 seconds now.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ Cylon.robot({
|
||||||
},
|
},
|
||||||
|
|
||||||
devices: {
|
devices: {
|
||||||
drone: { driver: "ardrone", connection:"ardrone" },
|
drone: { driver: "ardrone", connection: "ardrone" },
|
||||||
leapmotion: { driver: "leapmotion", connection:"leapmotion" },
|
leapmotion: { driver: "leapmotion", connection: "leapmotion" },
|
||||||
keyboard: { driver: "keyboard", connection:"keyboard" }
|
keyboard: { driver: "keyboard", connection: "keyboard" }
|
||||||
},
|
},
|
||||||
|
|
||||||
work: function(my) {
|
work: function(my) {
|
||||||
|
@ -92,11 +92,11 @@ Cylon.robot({
|
||||||
signal = handStartDirection[0] - hand.direction[0];
|
signal = handStartDirection[0] - hand.direction[0];
|
||||||
value = (horizontal - TURN_TRESHOLD) * TURN_SPEED_FACTOR;
|
value = (horizontal - TURN_TRESHOLD) * TURN_SPEED_FACTOR;
|
||||||
|
|
||||||
if (signal > 0){
|
if (signal > 0) {
|
||||||
my.drone.counterClockwise(value);
|
my.drone.counterClockwise(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signal < 0){
|
if (signal < 0) {
|
||||||
my.drone.clockwise(value);
|
my.drone.clockwise(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ Cylon.robot({
|
||||||
}
|
}
|
||||||
|
|
||||||
// DIRECTION LEFT/RIGHT
|
// DIRECTION LEFT/RIGHT
|
||||||
if ((Math.abs(hand.palmNormal[0])>DIRECTION_THRESHOLD)) {
|
if (Math.abs(hand.palmNormal[0]) > DIRECTION_THRESHOLD) {
|
||||||
if (hand.palmNormal[0] > 0) {
|
if (hand.palmNormal[0] > 0) {
|
||||||
value = Math.abs(
|
value = Math.abs(
|
||||||
Math.round(hand.palmNormal[0] * 10 + DIRECTION_THRESHOLD) *
|
Math.round(hand.palmNormal[0] * 10 + DIRECTION_THRESHOLD) *
|
||||||
|
|
|
@ -26,6 +26,7 @@ Cylon.robot({
|
||||||
my.salesforce.on("start", function() {
|
my.salesforce.on("start", function() {
|
||||||
my.salesforce.subscribe("/topic/SpheroMsgOutbound", function(data) {
|
my.salesforce.subscribe("/topic/SpheroMsgOutbound", function(data) {
|
||||||
var msg = "Sphero: " + data.sobject.Sphero_Name__c + ",";
|
var msg = "Sphero: " + data.sobject.Sphero_Name__c + ",";
|
||||||
|
|
||||||
msg += "Bucks: " + data.sobject.Bucks__c + ",";
|
msg += "Bucks: " + data.sobject.Bucks__c + ",";
|
||||||
msg += "SM_Id: " + data.sobject.Id;
|
msg += "SM_Id: " + data.sobject.Id;
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ bots.forEach(function(bot) {
|
||||||
bucks: "" + (my.totalBucks++)
|
bucks: "" + (my.totalBucks++)
|
||||||
});
|
});
|
||||||
|
|
||||||
var sf = Cylon.robots["salesforce"];
|
var sf = Cylon.robots.salesforce;
|
||||||
sf.devices.salesforce.push("SpheroController", "POST", data);
|
sf.devices.salesforce.push("SpheroController", "POST", data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ Cylon.robot({
|
||||||
|
|
||||||
my.sphero.setDataStreaming(["velocity"], { n: 40, m: 1, pcnt: 0 });
|
my.sphero.setDataStreaming(["velocity"], { n: 40, m: 1, pcnt: 0 });
|
||||||
my.sphero.on("data", function(data) {
|
my.sphero.on("data", function(data) {
|
||||||
if(!changingColor) {
|
if (!changingColor) {
|
||||||
var x = Math.abs(data[0]),
|
var x = Math.abs(data[0]),
|
||||||
y = Math.abs(data[1]);
|
y = Math.abs(data[1]);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@ Cylon.robot({
|
||||||
my.sphero.setColor("blue", true);
|
my.sphero.setColor("blue", true);
|
||||||
|
|
||||||
travis.repos({ owner_name: user, name: name }, function(err, res) {
|
travis.repos({ owner_name: user, name: name }, function(err, res) {
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
if (res.repo === undefined) { my.sphero.setColor("blue", true); }
|
if (res.repo === undefined) { my.sphero.setColor("blue", true); }
|
||||||
|
|
||||||
switch (res.repo.last_build_state) {
|
switch (res.repo.last_build_state) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ Basestar.prototype.proxyMethods = Utils.proxyFunctionsToObject;
|
||||||
Basestar.prototype.respond = function(event, callback, err) {
|
Basestar.prototype.respond = function(event, callback, err) {
|
||||||
var args = Array.prototype.slice.call(arguments, 3);
|
var args = Array.prototype.slice.call(arguments, 3);
|
||||||
|
|
||||||
if (!!err) {
|
if (err) {
|
||||||
this.emit("error", err);
|
this.emit("error", err);
|
||||||
} else {
|
} else {
|
||||||
this.emit.apply(this, [event].concat(args));
|
this.emit.apply(this, [event].concat(args));
|
||||||
|
|
|
@ -179,8 +179,9 @@ Cylon.toJSON = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
var readline = require("readline"),
|
var readline = require("readline");
|
||||||
io = { input: process.stdin, output: process.stdout };
|
|
||||||
|
var io = { input: process.stdin, output: process.stdout };
|
||||||
|
|
||||||
readline.createInterface(io).on("SIGINT", function() {
|
readline.createInterface(io).on("SIGINT", function() {
|
||||||
process.emit("SIGINT");
|
process.emit("SIGINT");
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* Licensed under the Apache 2.0 license.
|
* Licensed under the Apache 2.0 license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint camelcase: 0 */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Basestar = require("./basestar"),
|
var Basestar = require("./basestar"),
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* Licensed under the Apache 2.0 license.
|
* Licensed under the Apache 2.0 license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint no-sync: 0 */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var FS = require("fs"),
|
var FS = require("fs"),
|
||||||
|
@ -90,7 +92,7 @@ DigitalPin.prototype.digitalRead = function(interval) {
|
||||||
var error = "Error occurred while reading from pin " + this.pinNum;
|
var error = "Error occurred while reading from pin " + this.pinNum;
|
||||||
this.emit("error", error);
|
this.emit("error", error);
|
||||||
} else {
|
} else {
|
||||||
var readData = parseInt(data.toString());
|
var readData = parseInt(data.toString(), 10);
|
||||||
this.emit("digitalRead", readData);
|
this.emit("digitalRead", readData);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -20,7 +20,7 @@ require("./test/ping");
|
||||||
var missingModuleError = function(module) {
|
var missingModuleError = function(module) {
|
||||||
var str = "Cannot find the '" + module + "' module.\n";
|
var str = "Cannot find the '" + module + "' module.\n";
|
||||||
str += "This problem might be fixed by installing it with ";
|
str += "This problem might be fixed by installing it with ";
|
||||||
str +="'npm install " + module + "' and trying again.";
|
str += "'npm install " + module + "' and trying again.";
|
||||||
|
|
||||||
console.log(str);
|
console.log(str);
|
||||||
|
|
||||||
|
@ -97,12 +97,14 @@ var Registry = module.exports = {
|
||||||
|
|
||||||
search: function(entry, value) {
|
search: function(entry, value) {
|
||||||
for (var name in this.data) {
|
for (var name in this.data) {
|
||||||
|
if (this.data.hasOwnProperty(name)) {
|
||||||
var repo = this.data[name];
|
var repo = this.data[name];
|
||||||
|
|
||||||
if (repo[entry] && _.includes(repo[entry], value)) {
|
if (repo[entry] && _.includes(repo[entry], value)) {
|
||||||
return repo.module;
|
return repo.module;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ Robot.prototype.start = function(callback) {
|
||||||
this.startDevices,
|
this.startDevices,
|
||||||
start
|
start
|
||||||
], function(err, results) {
|
], function(err, results) {
|
||||||
if (!!err) {
|
if (err) {
|
||||||
this.log("fatal", "An error occured while trying to start the robot:");
|
this.log("fatal", "An error occured while trying to start the robot:");
|
||||||
this.log("fatal", err);
|
this.log("fatal", err);
|
||||||
|
|
||||||
|
|
|
@ -70,10 +70,10 @@ var Utils = module.exports = {
|
||||||
// Returns a function
|
// Returns a function
|
||||||
sleep: function sleep(ms) {
|
sleep: function sleep(ms) {
|
||||||
var start = Date.now(),
|
var start = Date.now(),
|
||||||
i;
|
|
||||||
|
|
||||||
while(Date.now() < start + ms) {
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
|
while (Date.now() < start + ms) {
|
||||||
|
i = i.toString();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,9 @@ function extend(base, source) {
|
||||||
base[i] = e;
|
base[i] = e;
|
||||||
} else if (typeof e === "object") {
|
} else if (typeof e === "object") {
|
||||||
base[i] = extend(base[i], e);
|
base[i] = extend(base[i], e);
|
||||||
} else {
|
} else if (!~base.indexOf(e)) {
|
||||||
if (!~base.indexOf(e)) {
|
|
||||||
base.push(e);
|
base.push(e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var key;
|
var key;
|
||||||
|
@ -41,15 +39,13 @@ function extend(base, source) {
|
||||||
for (key in source) {
|
for (key in source) {
|
||||||
if (typeof source[key] !== "object" || !source[key]) {
|
if (typeof source[key] !== "object" || !source[key]) {
|
||||||
base[key] = source[key];
|
base[key] = source[key];
|
||||||
} else {
|
} else if (base[key]) {
|
||||||
if (base[key]) {
|
|
||||||
extend(base[key], source[key]);
|
extend(base[key], source[key]);
|
||||||
} else {
|
} else {
|
||||||
base[key] = source[key];
|
base[key] = source[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
@ -92,8 +88,6 @@ function iterate(thing, fn, thisVal) {
|
||||||
fn.call(thisVal, value, key);
|
fn.call(thisVal, value, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pluck(collection, key) {
|
function pluck(collection, key) {
|
||||||
|
@ -165,8 +159,8 @@ function reduce(collection, iteratee, accumulator, thisVal) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate(collection, function(object, key) {
|
iterate(collection, function(object, name) {
|
||||||
accumulator = iteratee.call(thisVal, accumulator, object, key);
|
accumulator = iteratee.call(thisVal, accumulator, object, name);
|
||||||
});
|
});
|
||||||
|
|
||||||
return accumulator;
|
return accumulator;
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
* Licensed under the Apache 2.0 license.
|
* Licensed under the Apache 2.0 license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint no-extend-native: 0 */
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var max = Math.max,
|
var max = Math.max,
|
||||||
|
@ -68,7 +70,7 @@ module.exports.install = function() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val < 0){
|
if (val < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@
|
||||||
"sinon-chai": "2.7.0",
|
"sinon-chai": "2.7.0",
|
||||||
"chai": "2.2.0",
|
"chai": "2.2.0",
|
||||||
"mocha": "2.2.4",
|
"mocha": "2.2.4",
|
||||||
"sinon": "1.14.1"
|
"sinon": "1.14.1",
|
||||||
|
"eslint": "0.19.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
env:
|
||||||
|
mocha: true
|
||||||
|
|
||||||
|
rules:
|
||||||
|
no-unused-expressions: 0
|
||||||
|
max-nested-callbacks: 0
|
||||||
|
camelcase: 0
|
|
@ -1,12 +1,12 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
process.env.NODE_ENV = 'test';
|
process.env.NODE_ENV = "test";
|
||||||
|
|
||||||
var path = require('path');
|
var path = require("path");
|
||||||
|
|
||||||
var chai = require('chai'),
|
var chai = require("chai"),
|
||||||
sinon = require('sinon'),
|
sinon = require("sinon"),
|
||||||
sinonChai = require('sinon-chai');
|
sinonChai = require("sinon-chai");
|
||||||
|
|
||||||
chai.use(sinonChai);
|
chai.use(sinonChai);
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ global.stub = sinon.stub;
|
||||||
|
|
||||||
// convenience function to require modules in lib directory
|
// convenience function to require modules in lib directory
|
||||||
global.source = function(module) {
|
global.source = function(module) {
|
||||||
return require(path.normalize('./../lib/' + module));
|
return require(path.normalize("./../lib/" + module));
|
||||||
};
|
};
|
||||||
|
|
||||||
var Cylon = source('cylon');
|
var Cylon = source("cylon");
|
||||||
|
|
||||||
Cylon.config({
|
Cylon.config({
|
||||||
mode: "manual",
|
mode: "manual",
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Adaptor = source("adaptor"),
|
var Adaptor = source("adaptor"),
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Basestar = source("basestar"),
|
var Basestar = source("basestar"),
|
||||||
|
@ -82,11 +81,16 @@ describe("Basestar", function() {
|
||||||
errListener = spy();
|
errListener = spy();
|
||||||
child = new Child();
|
child = new Child();
|
||||||
child.on("error", errListener);
|
child.on("error", errListener);
|
||||||
child.respond("event", callback,
|
child.respond(
|
||||||
"Error on event!", "arg1", 2, { three: true });
|
"event",
|
||||||
|
callback,
|
||||||
|
"Error on event!",
|
||||||
|
"arg1",
|
||||||
|
2,
|
||||||
|
{ three: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
it ("emits an error event", function() {
|
it("emits an error event", function() {
|
||||||
expect(errListener).to.be.calledWith("Error on event!");
|
expect(errListener).to.be.calledWith("Error on event!");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Cylon = source("cylon"),
|
var Cylon = source("cylon"),
|
||||||
|
@ -46,7 +45,7 @@ describe("Cylon", function() {
|
||||||
var robot = Cylon.robot(opts);
|
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);
|
expect(Cylon.robots.Ultron).to.be.eql(robot);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("avoids duplicating names", function() {
|
it("avoids duplicating names", function() {
|
||||||
|
@ -99,8 +98,8 @@ describe("Cylon", function() {
|
||||||
bot2 = { start: spy() };
|
bot2 = { start: spy() };
|
||||||
|
|
||||||
Cylon.robots = {
|
Cylon.robots = {
|
||||||
"bot1": bot1,
|
bot1: bot1,
|
||||||
"bot2": bot2
|
bot2: bot2
|
||||||
};
|
};
|
||||||
|
|
||||||
Cylon.start();
|
Cylon.start();
|
||||||
|
@ -163,8 +162,8 @@ describe("Cylon", function() {
|
||||||
bot2 = { halt: spy() };
|
bot2 = { halt: spy() };
|
||||||
|
|
||||||
Cylon.robots = {
|
Cylon.robots = {
|
||||||
"bot1": bot1,
|
bot1: bot1,
|
||||||
"bot2": bot2
|
bot2: bot2
|
||||||
};
|
};
|
||||||
|
|
||||||
Cylon.halt();
|
Cylon.halt();
|
||||||
|
@ -175,14 +174,14 @@ describe("Cylon", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#toJSON", function() {
|
describe("#toJSON", function() {
|
||||||
var json, bot1, bot2, echo;
|
var json, bot1, bot2;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
bot1 = new Robot();
|
bot1 = new Robot();
|
||||||
bot2 = new Robot();
|
bot2 = new Robot();
|
||||||
|
|
||||||
Cylon.robots = { "bot1": bot1, "bot2": bot2 };
|
Cylon.robots = { bot1: bot1, bot2: bot2 };
|
||||||
Cylon.commands.echo = echo = function(arg) { return arg; };
|
Cylon.commands.echo = function(arg) { return arg; };
|
||||||
|
|
||||||
json = Cylon.toJSON();
|
json = Cylon.toJSON();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* jshint expr:true */
|
/* eslint no-sync: 0 */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Driver = source("driver"),
|
var Driver = source("driver"),
|
||||||
|
@ -77,7 +76,7 @@ describe("Driver", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("#toJSON", function() {
|
describe("#toJSON", function() {
|
||||||
var driver, json;
|
var json;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
driver = new Driver({
|
driver = new Driver({
|
||||||
|
@ -125,8 +124,8 @@ describe("Driver", function() {
|
||||||
var commands = ["helloWorld", "otherTestCommand"],
|
var commands = ["helloWorld", "otherTestCommand"],
|
||||||
snake_case = ["hello_world", "other_test_command"];
|
snake_case = ["hello_world", "other_test_command"];
|
||||||
|
|
||||||
commands.forEach(function(cmd) {
|
commands.forEach(function(name) {
|
||||||
driver[cmd] = spy();
|
driver[name] = spy();
|
||||||
});
|
});
|
||||||
|
|
||||||
driver.setupCommands(commands);
|
driver.setupCommands(commands);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Utils = source("io/utils.js");
|
var Utils = source("io/utils.js");
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Logger = source("logger"),
|
var Logger = source("logger"),
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var logger = source("logger/basic_logger");
|
var logger = source("logger/basic_logger");
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Registry = source("registry");
|
var Registry = source("registry");
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Driver = source("driver"),
|
var Driver = source("driver"),
|
||||||
|
@ -85,8 +84,6 @@ describe("Robot", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
context("if no commands are provided", function() {
|
context("if no commands are provided", function() {
|
||||||
var robot;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
robot = new Robot({
|
robot = new Robot({
|
||||||
name: "NewBot",
|
name: "NewBot",
|
||||||
|
@ -101,8 +98,6 @@ describe("Robot", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
context("if a commands function is provided", function() {
|
context("if a commands function is provided", function() {
|
||||||
var robot;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
robot = new Robot({
|
robot = new Robot({
|
||||||
name: "NewBot",
|
name: "NewBot",
|
||||||
|
@ -147,8 +142,6 @@ describe("Robot", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
context("if a commands object is provided", function() {
|
context("if a commands object is provided", function() {
|
||||||
var robot;
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
robot = new Robot({
|
robot = new Robot({
|
||||||
name: "NewBot",
|
name: "NewBot",
|
||||||
|
@ -246,7 +239,7 @@ describe("Robot", function() {
|
||||||
it("contains the robot's events, or an empty array", function() {
|
it("contains the robot's events, or an empty array", function() {
|
||||||
expect(json.events).to.eql(["hello", "world"]);
|
expect(json.events).to.eql(["hello", "world"]);
|
||||||
|
|
||||||
var bot = new Robot();
|
bot = new Robot();
|
||||||
expect(bot.toJSON().events).to.be.eql([]);
|
expect(bot.toJSON().events).to.be.eql([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* jshint expr:true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var utils = source("utils");
|
var utils = source("utils");
|
||||||
|
@ -207,7 +206,7 @@ describe("Utils", function() {
|
||||||
|
|
||||||
describe("#fetch", function() {
|
describe("#fetch", function() {
|
||||||
var fetch = utils.fetch,
|
var fetch = utils.fetch,
|
||||||
obj = { property: "hello world", "false": false, "null": null };
|
obj = { property: "hello world", false: false, null: null };
|
||||||
|
|
||||||
context("if the property exists on the object", function() {
|
context("if the property exists on the object", function() {
|
||||||
it("returns the value", function() {
|
it("returns the value", function() {
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe("Helpers", function() {
|
||||||
vegetables: ["beet"],
|
vegetables: ["beet"],
|
||||||
thing: null,
|
thing: null,
|
||||||
otherThing: "hello!",
|
otherThing: "hello!",
|
||||||
data: [{ "user": "barney" }, { "user": "fred" }]
|
data: [{ user: "barney" }, { user: "fred" }]
|
||||||
};
|
};
|
||||||
|
|
||||||
var source = {
|
var source = {
|
||||||
|
@ -19,7 +19,7 @@ describe("Helpers", function() {
|
||||||
vegetables: ["carrot"],
|
vegetables: ["carrot"],
|
||||||
thing: "hello!",
|
thing: "hello!",
|
||||||
otherThing: null,
|
otherThing: null,
|
||||||
data: [{ "age": 36 }, { "age": 40 }]
|
data: [{ age: 36 }, { age: 40 }]
|
||||||
};
|
};
|
||||||
|
|
||||||
var expected = {
|
var expected = {
|
||||||
|
@ -37,7 +37,7 @@ describe("Helpers", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("isObject", function() {
|
describe("isObject", function() {
|
||||||
var fn =_.isObject;
|
var fn = _.isObject;
|
||||||
|
|
||||||
it("checks if a value is an Object", function() {
|
it("checks if a value is an Object", function() {
|
||||||
var Klass = function() {},
|
var Klass = function() {},
|
||||||
|
@ -54,7 +54,7 @@ describe("Helpers", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("isFunction", function() {
|
describe("isFunction", function() {
|
||||||
var fn =_.isFunction;
|
var fn = _.isFunction;
|
||||||
|
|
||||||
it("checks if a value is a Function", function() {
|
it("checks if a value is a Function", function() {
|
||||||
expect(fn(function() {})).to.be.eql(true);
|
expect(fn(function() {})).to.be.eql(true);
|
||||||
|
@ -224,14 +224,14 @@ describe("Helpers", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("defaults to the first value for the accumulator", function() {
|
it("defaults to the first value for the accumulator", function() {
|
||||||
var obj = {
|
var object = {
|
||||||
a: { name: "hello" },
|
a: { name: "hello" },
|
||||||
b: { name: "world" }
|
b: { name: "world" }
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(_.reduce(arr, add)).to.be.eql(21);
|
expect(_.reduce(arr, add)).to.be.eql(21);
|
||||||
expect(
|
expect(
|
||||||
_.reduce(obj, function(acc, val) {
|
_.reduce(object, function(acc, val) {
|
||||||
acc.name += " " + val.name;
|
acc.name += " " + val.name;
|
||||||
return acc;
|
return acc;
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
adaptors: [ 'test-adaptor' ],
|
adaptors: [ "test-adaptor" ],
|
||||||
drivers: [ 'test-driver' ]
|
drivers: [ "test-driver" ]
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue