Simplify rendering of "more topics" link.

We now use a template to render the "more topics" link.

We also remove an unnecessary conditional and an unnecessary
attribute.

Finally, our unit tests are a bit more granular now.
This commit is contained in:
Steve Howell
2017-09-21 11:44:31 -07:00
committed by Tim Abbott
parent 544bbab480
commit 490935249c
4 changed files with 25 additions and 17 deletions

View File

@@ -828,6 +828,13 @@ function render(template_name, args) {
assert($(html).find(".message_reaction").has(".emoji .emoji-smile"));
}());
(function more_topics() {
var html = render('more_topics');
global.write_handlebars_output("more_topics", html);
assert($(html).hasClass('show-more-topics'));
}());
(function new_stream_users() {
var args = {
users: [

View File

@@ -82,7 +82,13 @@ zrequire('topic_list');
assert.equal(topic_list.active_stream_id(), undefined);
var widget = topic_list.rebuild(parent_elem, stream_id);
var widget = topic_list.widget(parent_elem, stream_id);
widget.build_more_topics_section = function () {
return $('<more topics>');
};
widget.build();
assert(widget.is_for_stream(stream_id));
assert.equal(widget.get_parent(), parent_elem);
@@ -90,8 +96,7 @@ zrequire('topic_list');
assert(checked_mutes);
assert(rendered);
assert.equal(list_items[0].html(), '<topic list item>');
assert.equal(list_items[1], $('<li class="show-more-topics">'));
assert.equal(list_items[1].html(), '<more topics>');
assert(attached_to_parent);
assert.equal(topic_list.active_stream_id(), stream_id);
}());