2017-08-10 06:22:15 -04:00
|
|
|
import createStore from 'helpers/create-store';
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.module("Discourse.NavItem", {
|
|
|
|
beforeEach() {
|
2014-01-09 13:48:47 -05:00
|
|
|
Ember.run(function() {
|
2015-04-30 16:04:58 -04:00
|
|
|
const asianCategory = Discourse.Category.create({name: '确实是这样', id: 343434});
|
2014-01-09 13:48:47 -05:00
|
|
|
Discourse.Site.currentProp('categories').addObject(asianCategory);
|
|
|
|
});
|
2013-06-17 13:04:54 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-06-14 13:57:58 -04:00
|
|
|
QUnit.test('href', assert =>{
|
|
|
|
assert.expect(4);
|
2013-06-17 13:04:54 -04:00
|
|
|
|
2013-06-17 13:23:22 -04:00
|
|
|
function href(text, expected, label) {
|
2017-06-14 13:57:58 -04:00
|
|
|
assert.equal(Discourse.NavItem.fromText(text, {}).get('href'), expected, label);
|
2013-06-17 13:23:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
href('latest', '/latest', 'latest');
|
|
|
|
href('categories', '/categories', 'categories');
|
2014-10-16 12:15:31 -04:00
|
|
|
href('category/bug', '/c/bug', 'English category name');
|
|
|
|
href('category/确实是这样', '/c/343434-category', 'Chinese category name');
|
2013-06-17 13:04:54 -04:00
|
|
|
});
|
2017-08-10 06:22:15 -04:00
|
|
|
|
|
|
|
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");
|
|
|
|
});
|