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, is_active_topic: false, url: '#narrow/stream/555-devel/topic/coding', }; assert.deepEqual(info, expected); rendered = true; return ''; }); 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 = $('