diff --git a/frontend_tests/node_tests/bot_data.js b/frontend_tests/node_tests/bot_data.js index e35425bbd9..1a97067afd 100644 --- a/frontend_tests/node_tests/bot_data.js +++ b/frontend_tests/node_tests/bot_data.js @@ -1,10 +1,9 @@ zrequire('people'); zrequire('bot_data'); -set_global('$', () => { - return {trigger: () => {}}; +set_global('settings_bots', { + render_bots: () => {}, }); -set_global('document', null); const page_params = { realm_bots: [{email: 'bot0@zulip.com', user_id: 42, full_name: 'Bot 0'}, diff --git a/frontend_tests/node_tests/settings_bots.js b/frontend_tests/node_tests/settings_bots.js index fb3ca3e2d9..680cede50a 100644 --- a/frontend_tests/node_tests/settings_bots.js +++ b/frontend_tests/node_tests/settings_bots.js @@ -16,7 +16,6 @@ set_global("avatar", {}); set_global('$', global.make_zjquery()); set_global('i18n', global.stub_i18n); -set_global('document', 'document-stub'); zrequire('bot_data'); zrequire('settings_bots'); diff --git a/static/js/bot_data.js b/static/js/bot_data.js index 26deaba312..ceff9cef67 100644 --- a/static/js/bot_data.js +++ b/static/js/bot_data.js @@ -12,7 +12,7 @@ var bot_data = (function () { 'config_data', 'service_name', 'token']; var send_change_event = _.debounce(function () { - $(document).trigger('zulip.bot_data_changed'); + settings_bots.render_bots(); }, 50); var set_can_admin = function bot_data__set_can_admin(bot) { diff --git a/static/js/settings_bots.js b/static/js/settings_bots.js index 789fbf704c..a9dc6e816e 100644 --- a/static/js/settings_bots.js +++ b/static/js/settings_bots.js @@ -51,7 +51,7 @@ exports.type_id_to_string = function (type_id) { return i18n.t(name); }; -function render_bots() { +exports.render_bots = function () { $('#active_bots_list').empty(); $('#inactive_bots_list').empty(); @@ -92,7 +92,7 @@ function render_bots() { $("#active_bots_list").hide(); $("#inactive_bots_list").show(); } -} +}; exports.generate_zuliprc_uri = function (bot_id) { var bot = bot_data.get(bot_id); @@ -208,9 +208,7 @@ exports.set_up = function () { $(this).attr("href", "data:application/octet-stream;charset=utf-8," + encodeURIComponent(content)); }); - // TODO: render bots xxxx - render_bots(); - $(document).on('zulip.bot_data_changed', render_bots); + exports.render_bots(); $.validator.addMethod("bot_local_part", function (value, element) {