Skip to content

Commit

Permalink
Tests: Make board instances the value of a property of the current test
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Jul 16, 2015
1 parent 4a8853c commit 838c313
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 42 deletions.
32 changes: 16 additions & 16 deletions test/accelerometer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function newBoard() {
exports["Accelerometer -- Analog"] = {

setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.accel = new Accelerometer({
pins: ["A0", "A1"],
freq: 100,
board: board
board: this.board
});

this.proto = [{
Expand Down Expand Up @@ -205,13 +205,13 @@ exports["Accelerometer -- Analog"] = {

exports["Accelerometer -- distinctZeroV"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.accel = new Accelerometer({
pins: ["A0", "A1", "A2"],
freq: 100,
board: board,
board: this.board,
zeroV: [300, 400, 500],
sensitivity: 100
});
Expand Down Expand Up @@ -247,12 +247,12 @@ exports["Accelerometer -- distinctZeroV"] = {

exports["Accelerometer -- autoCalibrate"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.accel = new Accelerometer({
pins: ["A0", "A1", "A2"],
board: board,
board: this.board,
sensitivity: 100,
autoCalibrate: true
});
Expand Down Expand Up @@ -294,14 +294,14 @@ exports["Accelerometer -- autoCalibrate"] = {
exports["Accelerometer -- ADXL335"] = {

setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.accel = new Accelerometer({
controller: "ADXL335",
pins: ["A0", "A1", "A2"],
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -342,15 +342,15 @@ exports["Accelerometer -- ADXL335"] = {
exports["Accelerometer -- MPU-6050"] = {

setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.i2cConfig = sinon.spy(MockFirmata.prototype, "i2cConfig");
this.i2cWrite = sinon.spy(MockFirmata.prototype, "i2cWrite");
this.i2cRead = sinon.spy(MockFirmata.prototype, "i2cRead");
this.accel = new Accelerometer({
controller: "MPU6050",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -429,14 +429,14 @@ exports["Accelerometer -- MPU-6050"] = {
exports["Accelerometer -- ADXL345"] = {

setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.i2cConfig = sinon.spy(MockFirmata.prototype, "i2cConfig");
this.i2cWrite = sinon.spy(MockFirmata.prototype, "i2cWrite");
this.i2cRead = sinon.spy(MockFirmata.prototype, "i2cRead");
this.accel = new Accelerometer({
controller: "ADXL345",
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -496,7 +496,7 @@ exports["Accelerometer -- ADXL345"] = {

exports["Accelerometer -- MMA7361"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.pinMode = sinon.spy(MockFirmata.prototype, "pinMode");
Expand All @@ -505,7 +505,7 @@ exports["Accelerometer -- MMA7361"] = {
controller: "MMA7361",
pins: ["A0", "A1", "A2"],
freq: 100,
board: board,
board: this.board,
sleepPin: 13
});

Expand Down Expand Up @@ -570,13 +570,13 @@ exports["Accelerometer -- MMA7361"] = {

exports["Accelerometer -- ESPLORA"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.accel = new Accelerometer({
controller: "ESPLORA",
freq: 100,
board: board
board: this.board
});

done();
Expand Down
52 changes: 26 additions & 26 deletions test/proximity.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ function newBoard() {

exports["Proximity"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "GP2Y0A21YK",
pin: "A1",
freq: 100,
board: board
board: this.board
});

this.instance = [{
Expand Down Expand Up @@ -66,14 +66,14 @@ exports["Proximity"] = {

exports["Proximity: GP2Y0A21YK"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "GP2Y0A21YK",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -148,14 +148,14 @@ exports["Proximity: GP2Y0A21YK"] = {

exports["Proximity: GP2D120XJ00F"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "GP2D120XJ00F",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -229,14 +229,14 @@ exports["Proximity: GP2D120XJ00F"] = {

exports["Proximity: GP2Y0A02YK0F"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "GP2Y0A02YK0F",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -310,14 +310,14 @@ exports["Proximity: GP2Y0A02YK0F"] = {

exports["Proximity: GP2Y0A41SK0F"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "GP2Y0A41SK0F",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -392,14 +392,14 @@ exports["Proximity: GP2Y0A41SK0F"] = {

exports["Proximity: GP2Y0A710K0F"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "GP2Y0A710K0F",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -473,14 +473,14 @@ exports["Proximity: GP2Y0A710K0F"] = {

exports["Proximity: MB1000"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "MB1000",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -555,14 +555,14 @@ exports["Proximity: MB1000"] = {

exports["Proximity: MB1010"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "MB1010",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -637,14 +637,14 @@ exports["Proximity: MB1010"] = {

exports["Proximity: MB1003"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "MB1003",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -719,14 +719,14 @@ exports["Proximity: MB1003"] = {

exports["Proximity: MB1230"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.analogRead = sinon.spy(MockFirmata.prototype, "analogRead");
this.proximity = new Proximity({
controller: "MB1230",
pin: "A1",
freq: 100,
board: board
board: this.board
});

done();
Expand Down Expand Up @@ -803,15 +803,15 @@ exports["Proximity: MB1230"] = {
exports["Proximity: SRF10"] = {

setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.i2cReadOnce = sinon.spy(MockFirmata.prototype, "i2cReadOnce");
this.i2cWrite = sinon.spy(MockFirmata.prototype, "i2cWrite");
this.i2cConfig = sinon.spy(MockFirmata.prototype, "i2cConfig");

this.proximity = new Proximity({
controller: "SRF10",
board: board
board: this.board
});

this.proto = [{
Expand Down Expand Up @@ -936,7 +936,7 @@ exports["Proximity: SRF10"] = {

exports["Proximity: HCSR04"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.pulseVal = 1000;

Expand All @@ -948,7 +948,7 @@ exports["Proximity: HCSR04"] = {
controller: "HCSR04",
pin: 7,
freq: 100,
board: board
board: this.board
});

this.proto = [{
Expand Down Expand Up @@ -1042,7 +1042,7 @@ exports["Proximity: HCSR04"] = {

exports["Proximity: LIDARLITE"] = {
setUp: function(done) {
var board = newBoard();
this.board = newBoard();
this.clock = sinon.useFakeTimers();
this.i2cConfig = sinon.spy(MockFirmata.prototype, "i2cConfig");
this.i2cWrite = sinon.spy(MockFirmata.prototype, "i2cWrite");
Expand All @@ -1056,7 +1056,7 @@ exports["Proximity: LIDARLITE"] = {
this.proximity = new Proximity({
controller: "LIDARLITE",
freq: 100,
board: board
board: this.board
});

this.proto = [{
Expand Down

0 comments on commit 838c313

Please sign in to comment.