2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-07 12:02:53 +08:00

FEATURE: Topic timeline widget

This commit is contained in:
Robin Ward 2016-05-17 13:03:08 -04:00
parent 751e354ca6
commit 559fa36c18
No known key found for this signature in database
GPG key ID: 0E091E2B4ED1B83D
27 changed files with 621 additions and 102 deletions

View file

@ -78,6 +78,29 @@ test('closestPostNumberFor', function() {
equal(postStream.closestPostNumberFor(0), 2, "it clips to the lower bound of the stream");
});
test('closestDaysAgoFor', function() {
const postStream = buildStream(1231);
postStream.set('timelineLookup', [[1, 10], [3, 8], [5, 1]]);
equal(postStream.closestDaysAgoFor(1), 10);
equal(postStream.closestDaysAgoFor(2), 10);
equal(postStream.closestDaysAgoFor(3), 8);
equal(postStream.closestDaysAgoFor(4), 8);
equal(postStream.closestDaysAgoFor(5), 1);
// Out of bounds
equal(postStream.closestDaysAgoFor(-1), 10);
equal(postStream.closestDaysAgoFor(0), 10);
equal(postStream.closestDaysAgoFor(10), 1);
});
test('closestDaysAgoFor - empty', function() {
const postStream = buildStream(1231);
postStream.set('timelineLookup', []);
equal(postStream.closestDaysAgoFor(1), null);
});
test('updateFromJson', function() {
const postStream = buildStream(1231);