reload: Use hash_util to get current hash encoded.

We do this change to limit the use of window in other modules,
specifically window.location.hash.
This commit is contained in:
Aman Agrawal
2021-03-04 12:36:30 +00:00
committed by Tim Abbott
parent e7129af8ac
commit c6a934da4c
3 changed files with 24 additions and 5 deletions

View File

@@ -105,6 +105,20 @@ run_test("test_get_hash_section", () => {
assert.deepEqual(hash_util.get_current_hash_section(), "your-account");
});
run_test("build_reload_url", () => {
location.hash = "#settings/your-account";
assert.equal(hash_util.build_reload_url(), "+oldhash=settings%2Fyour-account");
location.hash = "#test";
assert.equal(hash_util.build_reload_url(), "+oldhash=test");
location.hash = "#";
assert.equal(hash_util.build_reload_url(), "+oldhash=");
location.hash = "";
assert.equal(hash_util.build_reload_url(), "+oldhash=");
});
run_test("test_parse_narrow", () => {
assert.deepEqual(hash_util.parse_narrow(["narrow", "stream", "99-frontend"]), [
{negated: false, operator: "stream", operand: "frontend"},