Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

node tests: Move data setup higher in the file.

Steve Howell0dc597bceb16
diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js
index f86054d2061..1661e8fa03c 100644
--- a/frontend_tests/node_tests/typeahead_helper.js
+++ b/frontend_tests/node_tests/typeahead_helper.js
@@ -39,6 +39,68 @@ function assertSameEmails(lst1, lst2) {
);
}
+const a_bot = {
+ email: "[email protected]",
+ full_name: "A Zulip test bot",
+ is_admin: false,
+ is_bot: true,
+ user_id: 1,
+};
+
+const a_user = {
+ email: "[email protected]",
+ full_name: "A Zulip user",
+ is_admin: false,
+ is_bot: false,
+ user_id: 2,
+};
+
+const b_user_1 = {
+ email: "[email protected]",
+ full_name: "Bob 1",
+ is_admin: false,
+ is_bot: false,
+ user_id: 3,
+};
+
+const b_user_2 = {
+ email: "[email protected]",
+ full_name: "Bob 2",
+ is_admin: true,
+ is_bot: false,
+ user_id: 4,
+};
+
+const b_user_3 = {
+ email: "[email protected]",
+ full_name: "Bob 3",
+ is_admin: false,
+ is_bot: false,
+ user_id: 5,
+};
+
+const b_bot = {
+ email: "[email protected]",
+ full_name: "B bot",
+ is_admin: false,
+ is_bot: true,
+ user_id: 6,
+};
+
+const zman = {
+ email: "[email protected]",
+ full_name: "Zman",
+ is_admin: false,
+ is_bot: false,
+ user_id: 7,
+};
+
+const matches = [a_bot, a_user, b_user_1, b_user_2, b_user_3, b_bot, zman];
+
+for (const person of matches) {
+ people.add_active_user(person);
+}
+
stream_data.create_streams([
{name: "Dev", subscribed: true, color: "blue", stream_id: 1},
{name: "Linux", subscribed: true, color: "red", stream_id: 2},
@@ -226,68 +288,6 @@ run_test("sort_languages", () => {
assert.deepEqual(test_langs, ["j", "javascript", "java", "js"]);
});
-const a_bot = {
- email: "[email protected]",
- full_name: "A Zulip test bot",
- is_admin: false,
- is_bot: true,
- user_id: 1,
-};
-
-const a_user = {
- email: "[email protected]",
- full_name: "A Zulip user",
- is_admin: false,
- is_bot: false,
- user_id: 2,
-};
-
-const b_user_1 = {
- email: "[email protected]",
- full_name: "Bob 1",
- is_admin: false,
- is_bot: false,
- user_id: 3,
-};
-
-const b_user_2 = {
- email: "[email protected]",
- full_name: "Bob 2",
- is_admin: true,
- is_bot: false,
- user_id: 4,
-};
-
-const b_user_3 = {
- email: "[email protected]",
- full_name: "Bob 3",
- is_admin: false,
- is_bot: false,
- user_id: 5,
-};
-
-const b_bot = {
- email: "[email protected]",
- full_name: "B bot",
- is_admin: false,
- is_bot: true,
- user_id: 6,
-};
-
-const zman = {
- email: "[email protected]",
- full_name: "Zman",
- is_admin: false,
- is_bot: false,
- user_id: 7,
-};
-
-const matches = [a_bot, a_user, b_user_1, b_user_2, b_user_3, b_bot, zman];
-
-for (const person of matches) {
- people.add_active_user(person);
-}
-
function get_typeahead_result(query, current_stream, current_topic) {
const result = th.sort_recipients(
people.get_realm_users(),