Skip to content

Commit

Permalink
LSM303C IMU Extra unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sdesalas authored and rwaldron committed Feb 20, 2018
1 parent 578d6af commit 59bcf34
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test/compass.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var expecteds = {
[25, 0],
[45, 0]
],
x: [25, 258],
bearings: [{
name: "North",
abbr: "N",
Expand Down Expand Up @@ -42,6 +43,8 @@ var expecteds = {
name: "bearing"
}, {
name: "heading"
}, {
name: "raw"
}];

done();
Expand Down Expand Up @@ -84,7 +87,7 @@ var expecteds = {
},

data: function(test) {
test.expect(2);
test.expect(3);

var handler = this.i2cRead.getCall(0).args[3];
var spy = sinon.spy();
Expand All @@ -96,6 +99,7 @@ var expecteds = {

test.equal(spy.callCount, 1);
test.equal(Math.round(spy.args[0][0].heading), expecteds.data[index]);
test.equal(this.compass.raw.x, expecteds.x[index]);

test.done();
},
Expand Down Expand Up @@ -150,6 +154,8 @@ exports["Compass - MAG3110"] = {
name: "bearing"
}, {
name: "heading"
}, {
name: "raw"
}];

done();
Expand Down Expand Up @@ -194,7 +200,7 @@ exports["Compass - MAG3110"] = {
},

data: function(test) {
test.expect(3);
test.expect(4);

var status = this.i2cReadOnce.getCall(0).args[3];
var spy = sinon.spy();
Expand All @@ -215,12 +221,13 @@ exports["Compass - MAG3110"] = {
test.equal(spy.callCount, 1);
test.equal(spy.lastCall.args[0].heading, 3);
test.equal(this.compass.heading, 3);
test.deepEqual(this.compass.raw, { x: 153, y: -9, z: 102 });

test.done();
},

change: function(test) {
test.expect(7);
test.expect(8);


var status = this.i2cReadOnce.getCall(0).args[3];
Expand All @@ -246,6 +253,7 @@ exports["Compass - MAG3110"] = {
test.equal(this.compass.bearing.abbr, Compass.Points[1].abbr);
test.equal(this.compass.bearing.low, Compass.Points[1].low);
test.equal(this.compass.bearing.high, Compass.Points[1].high);
test.deepEqual(this.compass.raw, { x: 155, y: -14, z: 93 });

test.done();
},
Expand Down Expand Up @@ -275,6 +283,8 @@ exports["Compass - BNO055"] = {
name: "bearing"
}, {
name: "heading"
}, {
name: "raw"
}];

done();
Expand Down Expand Up @@ -318,7 +328,7 @@ exports["Compass - BNO055"] = {
},

dataAndChange: function(test) {
test.expect(4);
test.expect(5);

var driver = IMU.Drivers.get(this.board, "BNO055");
var data = this.sandbox.spy();
Expand Down Expand Up @@ -356,6 +366,7 @@ exports["Compass - BNO055"] = {
high: 185.62,
heading: 180,
});
test.deepEqual(this.compass.raw, { x: -52, y: -0, z: -200 });
test.done();
},

Expand Down

0 comments on commit 59bcf34

Please sign in to comment.