From 9c47a7be28bd2c47380d821d42f9c7b3dc86f71b Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Wed, 12 Jun 2024 08:48:34 +0000 Subject: [PATCH] hashchange: Add stub_with_args for admin.launch test. We've added a new stub function that records the arguments passed to a function called `stub_with_args`. We're only using this right now for `admin.launch` since we plan to test that arg in the upcoming commits for the redirect. For most of the other functions, the args are empty, so it doesn't make sense to refactor those tests to use this new stub. --- web/tests/hashchange.test.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/tests/hashchange.test.js b/web/tests/hashchange.test.js index 4cf2b34f00..d971341cc8 100644 --- a/web/tests/hashchange.test.js +++ b/web/tests/hashchange.test.js @@ -172,7 +172,13 @@ function test_helper({override, override_rewire, change_tab}) { }; } - stub(admin, "launch"); + function stub_with_args(module, func_name) { + module[func_name] = (...args) => { + events.push([module, func_name, args]); + }; + } + + stub_with_args(admin, "launch"); stub(admin, "build_page"); stub(drafts_overlay_ui, "launch"); stub(message_viewport, "stop_auto_scrolling"); @@ -363,7 +369,7 @@ run_test("hash_interactions", ({override, override_rewire}) => { [overlays, "close_for_hash_change"], [settings, "build_page"], [admin, "build_page"], - [admin, "launch"], + [admin, "launch", ["user-list-admin"]], ]); helper.clear_events();