mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
hash_util: Extract functions to be reused without window
.
These functions can now be used in other libraries without using window.location.hash in them and directly calling these functions.
This commit is contained in:
@@ -14,7 +14,7 @@ const ui_report = mock_esm("../../static/js/ui_report", {
|
||||
ui_report.displayed_error = true;
|
||||
},
|
||||
});
|
||||
set_global("location", {
|
||||
const location = set_global("location", {
|
||||
protocol: "https:",
|
||||
host: "example.com",
|
||||
pathname: "/",
|
||||
@@ -87,6 +87,9 @@ run_test("test_get_hash_category", () => {
|
||||
assert.deepEqual(hash_util.get_hash_category("#settings/display-settings"), "settings");
|
||||
assert.deepEqual(hash_util.get_hash_category("#drafts"), "drafts");
|
||||
assert.deepEqual(hash_util.get_hash_category("invites"), "invites");
|
||||
|
||||
location.hash = "#settings/your-account";
|
||||
assert.deepEqual(hash_util.get_current_hash_category(), "settings");
|
||||
});
|
||||
|
||||
run_test("test_get_hash_section", () => {
|
||||
@@ -97,6 +100,9 @@ run_test("test_get_hash_section", () => {
|
||||
|
||||
assert.equal(hash_util.get_hash_section("#drafts"), "");
|
||||
assert.equal(hash_util.get_hash_section(""), "");
|
||||
|
||||
location.hash = "#settings/your-account";
|
||||
assert.deepEqual(hash_util.get_current_hash_section(), "your-account");
|
||||
});
|
||||
|
||||
run_test("test_parse_narrow", () => {
|
||||
|
Reference in New Issue
Block a user