Skip to content

Commit

Permalink
Don't pass an undefined variable to every call to new Date().
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmehall committed Nov 12, 2014
1 parent d4550c5 commit 5e851f2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/apiTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var tessel = require('tessel');
var accelLib = require('../');

var portname = process.argv[2] || 'A';
var requireTime = new Date(milliseconds);
var requireTime = new Date();
var accel;

// Test connecting
Expand Down Expand Up @@ -131,28 +131,28 @@ test('getAcceleration', function (t) {
if(index == (data.length - 1)) {
t.end();
}
});
});
});
})

test('setOutputRate', function (t) {
// Check for all available output rates
async.eachSeries(accel.availableOutputRates(), function (rate, callback) {
// Function completes in a reasonable amount of time
var aboutToSet = new Date(milliseconds);
var aboutToSet = new Date();
accel.setOutputRate(rate, function (err) {
if(err) {
t.ok(false, 'error caught: ' + err);
}
var justSet = new Date(milliseconds);
var justSet = new Date();
t.ok(justSet - aboutToSet < 900, 'took too long to set output rate ' + rate);
// New output rate matches the requested output rate (10% tolerance)
var count = 0;
var thisTime;
var lastTime;
var freq;
accel.on('data', function (data) {
thisTime = new Date(milliseconds);
thisTime = new Date();
if(count) { // Check the first few data points
freq = 1000/(thisTime - lastTime);
if(rate > 12.5) {
Expand All @@ -174,18 +174,18 @@ test('setOutputRate', function (t) {
});
})

test('setScaleRange', function (t) {
test('setScaleRange', function (t) {
// Check for all available scale ranges
var ranges = accel.availableScaleRanges();
var collector = {};
async.eachSeries(accel.availableScaleRanges(), function (range, callback) {
// Function completes in a reasonable amount of time
var aboutToSet = new Date(milliseconds);
var aboutToSet = new Date();
accel.setScaleRange(range, function (err) {
if(err) {
t.ok(false, 'error caught: ' + err);
}
var justSet = new Date(milliseconds);
var justSet = new Date();
t.ok(justSet - aboutToSet < 300, 'timed out setting output rate ' + range);
accel.getAcceleration(function (err, data) {
if(err) {
Expand Down

0 comments on commit 5e851f2

Please sign in to comment.