subs: Move active_stream function to hash_util.

This function better belongs in hash_util since it relies on
the current window hash.
This commit is contained in:
Aman Agrawal
2021-03-15 05:57:14 +00:00
committed by Tim Abbott
parent c6a934da4c
commit b6f14c54e5
5 changed files with 28 additions and 18 deletions

View File

@@ -119,6 +119,15 @@ run_test("build_reload_url", () => {
assert.equal(hash_util.build_reload_url(), "+oldhash=");
});
run_test("test_active_stream", () => {
location.hash = "#streams/1/announce";
assert.equal(hash_util.active_stream().id, 1);
assert.equal(hash_util.active_stream().name, "announce");
location.hash = "#test/narrow";
assert.equal(hash_util.active_stream(), undefined);
});
run_test("test_parse_narrow", () => {
assert.deepEqual(hash_util.parse_narrow(["narrow", "stream", "99-frontend"]), [
{negated: false, operator: "stream", operand: "frontend"},

View File

@@ -21,6 +21,7 @@ mock_esm("../../static/js/browser_history", {update: noop});
mock_esm("../../static/js/hash_util", {
stream_edit_uri: noop,
by_stream_uri: noop,
active_stream: noop,
});
mock_esm("../../static/js/list_widget", {
create: () => ({init: noop}),