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>
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
set_global('$', global.make_zjquery());
|
|
|
|
zrequire('settings_muting');
|
|
zrequire('stream_data');
|
|
zrequire('muting');
|
|
set_global('muting_ui', {});
|
|
|
|
const noop = function () {};
|
|
|
|
const frontend = {
|
|
stream_id: 101,
|
|
name: 'frontend',
|
|
};
|
|
stream_data.add_sub('frontend', frontend);
|
|
|
|
run_test('settings', () => {
|
|
|
|
muting.add_muted_topic(frontend.stream_id, 'js');
|
|
let set_up_ui_called = false;
|
|
muting_ui.set_up_muted_topics_ui = function (opts) {
|
|
assert.deepEqual(opts, [[frontend.stream_id, 'js']]);
|
|
set_up_ui_called = true;
|
|
};
|
|
|
|
settings_muting.set_up();
|
|
|
|
const click_handler = $('body').get_on_handler('click', '.settings-unmute-topic');
|
|
assert.equal(typeof click_handler, 'function');
|
|
|
|
const event = {
|
|
stopImmediatePropagation: noop,
|
|
};
|
|
|
|
const fake_this = $.create('fake.settings-unmute-topic');
|
|
const tr_html = $('tr[data-topic="js"]');
|
|
fake_this.closest = function (opts) {
|
|
assert.equal(opts, 'tr');
|
|
return tr_html;
|
|
};
|
|
|
|
let data_called = 0;
|
|
tr_html.attr = function (opts) {
|
|
if (opts === 'data-stream-id') {
|
|
data_called += 1;
|
|
return frontend.stream_id;
|
|
}
|
|
if (opts === 'data-topic') {
|
|
data_called += 1;
|
|
return 'js';
|
|
}
|
|
};
|
|
|
|
let unmute_called = false;
|
|
muting_ui.unmute = function (stream_id, topic) {
|
|
assert.equal(stream_id, frontend.stream_id);
|
|
assert.equal(topic, 'js');
|
|
unmute_called = true;
|
|
};
|
|
click_handler.call(fake_this, event);
|
|
assert(unmute_called);
|
|
assert(set_up_ui_called);
|
|
assert.equal(data_called, 2);
|
|
});
|