Skip to content

Commit

Permalink
Fix test failing because of bad time offset (nightscout#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
mddub authored Jul 11, 2018
1 parent 23c03c6 commit f660d4b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,27 @@ describe('transform()', function() {
});

it('should discard data more than 20 minutes old', function() {
var now = Date.now();
var pumpTimeString = 'Oct 17, 2015 09:06:33';
var now = Date.parse('Oct 17, 2015 09:09:14');
var THRESHOLD = 20;
var boundary = now - THRESHOLD * 60 * 1000;
expect(
transform(
f.data({'currentServerTime': now, 'lastMedicalDeviceDataUpdateServerTime': boundary})
f.data({
'sMedicalDeviceTime': pumpTimeString,
'currentServerTime': now,
'lastMedicalDeviceDataUpdateServerTime': boundary,
})
).entries.length
).to.be.greaterThan(0);

expect(
transform(
f.data({'currentServerTime': now, 'lastMedicalDeviceDataUpdateServerTime': boundary - 1})
f.data({
'sMedicalDeviceTime': pumpTimeString,
'currentServerTime': now,
'lastMedicalDeviceDataUpdateServerTime': boundary - 1,
})
).entries.length
).to.be(0);
});
Expand Down

0 comments on commit f660d4b

Please sign in to comment.