Add timestamp update interval test

Break out delay computation into its own function and add tests,
including a regression test for #646.

// FREEBIE
This commit is contained in:
lilia 2016-01-27 12:10:42 -08:00
parent 9b390baea0
commit 080c233a93
2 changed files with 26 additions and 9 deletions

View file

@ -69,4 +69,18 @@ describe('TimestampView', function() {
checkStartsWith(ext_view, new Date(2012, 4, 5, 17, 30, 0), 'May 5, 2012');
});
it('updates at reasonable intervals', function() {
var view = new Whisper.TimestampView();
assert(view.computeDelay(1000) < 60 * 1000); // < minute
assert.strictEqual(view.computeDelay(1000 * 60 * 5), 60 * 1000); // minute
assert.strictEqual(view.computeDelay(1000 * 60 * 60 * 5), 60 * 60 * 1000); // hour
assert(view.computeDelay(6 * 24 * 60 * 60 * 1000) < 7 * 24 * 60 * 60 * 1000); // < week
// return falsey value for long ago dates that don't update
assert.notOk(view.computeDelay(1000 * 60 * 60 * 24 * 8));
});
});