2015-09-04 04:55:55 +08:00
|
|
|
import TopicTrackingState from 'discourse/models/topic-tracking-state';
|
2014-02-11 12:28:05 +08:00
|
|
|
|
2015-09-04 04:55:55 +08:00
|
|
|
module("model:topic-tracking-state");
|
2014-02-11 12:28:05 +08:00
|
|
|
|
2015-09-04 04:55:55 +08:00
|
|
|
test("sync", function (assert) {
|
|
|
|
const state = TopicTrackingState.create();
|
2014-02-11 12:28:05 +08:00
|
|
|
state.states["t111"] = {last_read_post_number: null};
|
|
|
|
|
|
|
|
state.updateSeen(111, 7);
|
2015-09-04 04:55:55 +08:00
|
|
|
const list = {topics: [{
|
2014-02-11 12:28:05 +08:00
|
|
|
highest_post_number: null,
|
|
|
|
id: 111,
|
|
|
|
unread: 10,
|
|
|
|
new_posts: 10
|
2015-09-04 04:55:55 +08:00
|
|
|
}]};
|
2014-02-11 12:28:05 +08:00
|
|
|
|
|
|
|
state.sync(list, "new");
|
2015-09-04 04:55:55 +08:00
|
|
|
assert.equal(list.topics.length, 0, "expect new topic to be removed as it was seen");
|
2014-02-11 12:28:05 +08:00
|
|
|
});
|