Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
node tests: Directly test simple stream_pill helpers.
Steve Howell0452f49c9733
diff --git a/frontend_tests/node_tests/stream_pill.js b/frontend_tests/node_tests/stream_pill.jsindex 2295e936e28..9d64cd2b217 100644--- a/frontend_tests/node_tests/stream_pill.js+++ b/frontend_tests/node_tests/stream_pill.js@@ -10,17 +10,17 @@ const stream_data = zrequire("stream_data");const stream_pill = zrequire("stream_pill");const denmark = {- stream_id: 1,+ stream_id: 101,name: "Denmark",subscribed: true,};const sweden = {- stream_id: 2,+ stream_id: 102,name: "Sweden",subscribed: false,};-peer_data.set_subscribers(denmark.stream_id, [1, 2, 3]);+peer_data.set_subscribers(denmark.stream_id, [1, 2, 3, 77]);peer_data.set_subscribers(sweden.stream_id, [1, 2, 3, 4, 5]);const denmark_pill = {@@ -56,3 +56,19 @@ run_test("create_item", () => {run_test("get_stream_id", () => {assert.equal(stream_pill.get_stream_name_from_item(denmark_pill), denmark.name);});++run_test("get_user_ids", () => {+ const items = [denmark_pill, sweden_pill];+ const widget = {items: () => items};++ const user_ids = stream_pill.get_user_ids(widget);+ assert.deepEqual(user_ids, [1, 2, 3, 4, 5, 77]);+});++run_test("get_stream_ids", () => {+ const items = [denmark_pill, sweden_pill];+ const widget = {items: () => items};++ const stream_ids = stream_pill.get_stream_ids(widget);+ assert.deepEqual(stream_ids, [101, 102]);+});diff --git a/static/js/stream_pill.js b/static/js/stream_pill.jsindex 55036bb3e44..c2c23e020da 100644--- a/static/js/stream_pill.js+++ b/static/js/stream_pill.js@@ -54,6 +54,7 @@ export function get_user_ids(pill_widget) {user_ids = Array.from(new Set(user_ids));user_ids = user_ids.filter(Boolean);+ user_ids.sort((a, b) => a - b);return user_ids;}