FIX: navigation item counters weren't updating properly

This commit is contained in:
Régis Hanol
2017-08-10 12:22:15 +02:00
parent f7d3702454
commit 05a74d2534
3 changed files with 20 additions and 7 deletions

View File

@ -1,3 +1,5 @@
import createStore from 'helpers/create-store';
QUnit.module("Discourse.NavItem", {
beforeEach() {
Ember.run(function() {
@ -19,3 +21,15 @@ QUnit.test('href', assert =>{
href('category/bug', '/c/bug', 'English category name');
href('category/确实是这样', '/c/343434-category', 'Chinese category name');
});
QUnit.test("count", assert => {
const navItem = createStore().createRecord("nav-item", { name: "new" });
assert.equal(navItem.get("count"), 0, "it has no count by default");
const tracker = navItem.get("topicTrackingState");
tracker.states["t1"] = { topic_id: 1, last_read_post_number: null };
tracker.incrementMessageCount();
assert.equal(navItem.get("count"), 1, "it updates when a new message arrives");
});