mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Show time gap between posts if more than a few days
This commit is contained in:
@@ -26,6 +26,40 @@ test('defaults', function() {
|
||||
present(postStream.get('topic'));
|
||||
});
|
||||
|
||||
test('daysSincePrevious when appending', function(assert) {
|
||||
const postStream = buildStream(10000001, [1,2,3]);
|
||||
const store = postStream.store;
|
||||
|
||||
const p1 = store.createRecord('post', {id: 1, post_number: 1, created_at: "2015-05-29T18:17:35.868Z"}),
|
||||
p2 = store.createRecord('post', {id: 2, post_number: 2, created_at: "2015-06-01T01:07:25.761Z"}),
|
||||
p3 = store.createRecord('post', {id: 3, post_number: 3, created_at: "2015-06-02T01:07:25.761Z"});
|
||||
|
||||
postStream.appendPost(p1);
|
||||
postStream.appendPost(p2);
|
||||
postStream.appendPost(p3);
|
||||
|
||||
assert.ok(!p1.get('daysSincePrevious'));
|
||||
assert.equal(p2.get('daysSincePrevious'), 2);
|
||||
assert.equal(p3.get('daysSincePrevious'), 1);
|
||||
});
|
||||
|
||||
test('daysSincePrevious when prepending', function(assert) {
|
||||
const postStream = buildStream(10000001, [1,2,3]);
|
||||
const store = postStream.store;
|
||||
|
||||
const p1 = store.createRecord('post', {id: 1, post_number: 1, created_at: "2015-05-29T18:17:35.868Z"}),
|
||||
p2 = store.createRecord('post', {id: 2, post_number: 2, created_at: "2015-06-01T01:07:25.761Z"}),
|
||||
p3 = store.createRecord('post', {id: 3, post_number: 3, created_at: "2015-06-02T01:07:25.761Z"});
|
||||
|
||||
postStream.prependPost(p3);
|
||||
postStream.prependPost(p2);
|
||||
postStream.prependPost(p1);
|
||||
|
||||
assert.ok(!p1.get('daysSincePrevious'));
|
||||
assert.equal(p2.get('daysSincePrevious'), 2);
|
||||
assert.equal(p3.get('daysSincePrevious'), 1);
|
||||
});
|
||||
|
||||
test('appending posts', function() {
|
||||
const postStream = buildStream(4567, [1, 3, 4]);
|
||||
const store = postStream.store;
|
||||
@@ -96,8 +130,8 @@ test("removePosts", function() {
|
||||
const store = postStream.store;
|
||||
|
||||
const p1 = store.createRecord('post', {id: 1, post_number: 2}),
|
||||
p2 = store.createRecord('post', {id: 2, post_number: 3}),
|
||||
p3 = store.createRecord('post', {id: 3, post_number: 4});
|
||||
p2 = store.createRecord('post', {id: 2, post_number: 3}),
|
||||
p3 = store.createRecord('post', {id: 3, post_number: 4});
|
||||
|
||||
postStream.appendPost(p1);
|
||||
postStream.appendPost(p2);
|
||||
|
||||
Reference in New Issue
Block a user