mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
This commit was originally automatically generated using `tools/lint --only=eslint --fix`. It was then modified by tabbott to contain only changes to a set of files that are unlikely to result in significant merge conflicts with any open pull request, excluding about 20 files. His plan is to merge the remaining changes with more precise care, potentially involving merging parts of conflicting pull requests before running the `eslint --fix` operation. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
102 lines
2.4 KiB
JavaScript
102 lines
2.4 KiB
JavaScript
set_global('$', global.make_zjquery());
|
|
set_global('i18n', global.stub_i18n);
|
|
|
|
set_global('narrow_state', {});
|
|
set_global('unread', {});
|
|
set_global('muting', {});
|
|
set_global('stream_popover', {});
|
|
set_global('message_list', {});
|
|
|
|
zrequire('hash_util');
|
|
zrequire('stream_data');
|
|
zrequire('unread');
|
|
zrequire('topic_data');
|
|
zrequire('topic_list');
|
|
|
|
const devel = {
|
|
stream_id: 555,
|
|
name: 'devel',
|
|
};
|
|
|
|
stream_data.add_sub('devel', devel);
|
|
|
|
run_test('topic_list_build_widget', () => {
|
|
|
|
topic_data.reset();
|
|
topic_data.add_message({
|
|
stream_id: devel.stream_id,
|
|
topic_name: 'coding',
|
|
message_id: 400,
|
|
});
|
|
|
|
stream_popover.hide_topic_popover = function () {};
|
|
|
|
narrow_state.topic = function () {
|
|
return 'testing';
|
|
};
|
|
|
|
unread.num_unread_for_topic = function () {
|
|
return 3;
|
|
};
|
|
|
|
let checked_mutes;
|
|
let rendered;
|
|
|
|
global.stub_templates(function (name, info) {
|
|
assert.equal(name, 'topic_list_item');
|
|
const expected = {
|
|
topic_name: 'coding',
|
|
unread: 3,
|
|
is_zero: false,
|
|
is_muted: false,
|
|
url: '#narrow/stream/555-devel/topic/coding',
|
|
};
|
|
assert.deepEqual(info, expected);
|
|
rendered = true;
|
|
return '<topic list item>';
|
|
});
|
|
|
|
muting.is_topic_muted = function (stream_id, topic_name) {
|
|
assert.equal(stream_id, devel.stream_id);
|
|
assert.equal(topic_name, 'coding');
|
|
checked_mutes = true;
|
|
return false;
|
|
};
|
|
|
|
const ul = $('<ul class="topic-list">');
|
|
|
|
const list_items = [];
|
|
|
|
ul.append = function (item) {
|
|
list_items.push(item);
|
|
};
|
|
|
|
const parent_elem = $.create('parent_elem');
|
|
let attached_to_parent;
|
|
|
|
parent_elem.append = function (child) {
|
|
assert.equal(child, ul);
|
|
attached_to_parent = true;
|
|
};
|
|
|
|
assert.equal(topic_list.active_stream_id(), undefined);
|
|
|
|
const widget = topic_list.widget(parent_elem, devel.stream_id);
|
|
|
|
widget.build_more_topics_section = function () {
|
|
return $('<more topics>');
|
|
};
|
|
|
|
widget.build();
|
|
|
|
assert(widget.get_stream_id(), devel.stream_id);
|
|
assert.equal(widget.get_parent(), parent_elem);
|
|
|
|
assert(checked_mutes);
|
|
assert(rendered);
|
|
assert.equal(list_items[0].html(), '<topic list item>');
|
|
assert.equal(list_items[1].html(), '<more topics>');
|
|
assert(attached_to_parent);
|
|
|
|
});
|