mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
node tests: Remove complicated topic_list test.
This test mostly tests how we glue everything together, but I want to change that in an upcoming commit. Also, the data stuff that it tests is now better covered by the test recent tests I added.
This commit is contained in:
@@ -1,10 +1,6 @@
|
|||||||
set_global('$', global.make_zjquery());
|
|
||||||
set_global('i18n', global.stub_i18n);
|
|
||||||
|
|
||||||
set_global('narrow_state', {});
|
set_global('narrow_state', {});
|
||||||
set_global('unread', {});
|
set_global('unread', {});
|
||||||
set_global('muting', {});
|
set_global('muting', {});
|
||||||
set_global('stream_popover', {});
|
|
||||||
set_global('message_list', {});
|
set_global('message_list', {});
|
||||||
|
|
||||||
zrequire('hash_util');
|
zrequire('hash_util');
|
||||||
@@ -13,23 +9,16 @@ zrequire('unread');
|
|||||||
zrequire('topic_data');
|
zrequire('topic_data');
|
||||||
zrequire('topic_list');
|
zrequire('topic_list');
|
||||||
|
|
||||||
const devel = {
|
|
||||||
stream_id: 555,
|
|
||||||
name: 'devel',
|
|
||||||
};
|
|
||||||
|
|
||||||
const general = {
|
const general = {
|
||||||
stream_id: 556,
|
stream_id: 556,
|
||||||
name: 'general',
|
name: 'general',
|
||||||
};
|
};
|
||||||
|
|
||||||
stream_data.add_sub('devel', devel);
|
|
||||||
stream_data.add_sub('general', general);
|
stream_data.add_sub('general', general);
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
narrow_state.topic = () => undefined;
|
narrow_state.topic = () => undefined;
|
||||||
topic_data.reset();
|
topic_data.reset();
|
||||||
stream_popover.hide_topic_popover = function () {};
|
|
||||||
muting.is_topic_muted = () => false;
|
muting.is_topic_muted = () => false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,80 +159,3 @@ run_test('get_list_info unreads', () => {
|
|||||||
'topic 8',
|
'topic 8',
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test('topic_list_build_widget', () => {
|
|
||||||
clear();
|
|
||||||
|
|
||||||
topic_data.get_recent_names = () => {
|
|
||||||
return ['coding'];
|
|
||||||
};
|
|
||||||
|
|
||||||
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,
|
|
||||||
is_active_topic: 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);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user