From 764b83b89043f08a80b5d22120c055234ea74a1a Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 16 Mar 2021 11:06:21 +0000 Subject: [PATCH] node tests: Remove stub_channel_get(). A few years ago I introduced the anti-pattern of automatically calling success functions within channel.get stubs. It's better to just capture the success function and call it explicitly. Also, we now have override(), so it's easy to inline these types of things in a safe way. --- frontend_tests/node_tests/compose_actions.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend_tests/node_tests/compose_actions.js b/frontend_tests/node_tests/compose_actions.js index 4defc1c2d9..f42f76273b 100644 --- a/frontend_tests/node_tests/compose_actions.js +++ b/frontend_tests/node_tests/compose_actions.js @@ -62,12 +62,6 @@ const respond_to_message = compose_actions.respond_to_message; const reply_with_mention = compose_actions.reply_with_mention; const quote_and_reply = compose_actions.quote_and_reply; -function stub_channel_get(success_value) { - channel.get = (opts) => { - opts.success(success_value); - }; -} - function assert_visible(sel) { assert($(sel).visible()); } @@ -337,8 +331,10 @@ test("quote_and_reply", (override) => { sender_id: 90, }; hash_util.by_conversation_and_time_uri = () => "link_to_message"; - stub_channel_get({ - raw_content: "Testing.", + + let success_function; + override(channel, "get", (opts) => { + success_function = opts.success; }); current_msg_list.selected_id = () => 100; @@ -360,6 +356,10 @@ test("quote_and_reply", (override) => { "@_**Steve Stephenson|90** [said](link_to_message):\n```quote\nTesting.\n```"; quote_and_reply(opts); + + success_function({ + raw_content: "Testing.", + }); assert(replaced); selected_message = {