diff --git a/tools/test-js-with-node b/tools/test-js-with-node index 83f62b3737..8400687832 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -298,6 +298,7 @@ EXEMPT_FILES = make_set( "web/src/zform.js", "web/src/zulip.js", "web/src/zulip_test.ts", + "web/tests/lib/example_user.js", "web/tests/lib/mdiff.js", "web/tests/lib/real_jquery.js", "web/tests/lib/zjquery_element.js", diff --git a/web/tests/example1.test.js b/web/tests/example1.test.js index fde2d1f340..5e959433af 100644 --- a/web/tests/example1.test.js +++ b/web/tests/example1.test.js @@ -10,6 +10,7 @@ const {strict: assert} = require("assert"); const {make_stream} = require("./lib/example_stream"); +const {make_user} = require("./lib/example_user"); const {zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); @@ -34,11 +35,11 @@ assert.ok(util.find_stream_wildcard_mentions("mention @**everyone**")); // * change the data // * get a true value -const isaac = { +const isaac = make_user({ email: "isaac@example.com", user_id: 30, full_name: "Isaac Newton", -}; +}); // The `people` object is a very fundamental object in the // Zulip app. You can learn a lot more about it by reading diff --git a/web/tests/example2.test.js b/web/tests/example2.test.js index 859c4d7f83..d2c6fe47dd 100644 --- a/web/tests/example2.test.js +++ b/web/tests/example2.test.js @@ -3,6 +3,7 @@ const {strict: assert} = require("assert"); const {make_stream} = require("./lib/example_stream"); +const {make_user} = require("./lib/example_user"); const {zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); @@ -23,11 +24,11 @@ const unread = zrequire("unread"); // test module, but you can also do this within tests. Here we // will set up things at the top. -const isaac = { +const isaac = make_user({ email: "isaac@example.com", user_id: 30, full_name: "Isaac Newton", -}; +}); const denmark_stream = make_stream({ color: "blue", diff --git a/web/tests/example4.test.js b/web/tests/example4.test.js index 067bb4cb52..2eb60c3f94 100644 --- a/web/tests/example4.test.js +++ b/web/tests/example4.test.js @@ -2,6 +2,7 @@ const {strict: assert} = require("assert"); +const {make_bot} = require("./lib/example_user"); const {mock_esm, zrequire} = require("./lib/namespace"); const {run_test, noop} = require("./lib/test"); @@ -65,12 +66,11 @@ const user_profile = mock_esm("../src/user_profile"); const people = zrequire("people"); const server_events_dispatch = zrequire("server_events_dispatch"); -const bob = { +const bob = make_bot({ email: "bob@example.com", user_id: 33, full_name: "Bob Roberts", - is_bot: true, -}; +}); run_test("add users with event", ({override}) => { people.init(); @@ -116,12 +116,11 @@ run_test("update user with event", ({override}) => { people.init(); people.add_active_user(bob); - const new_bob = { + const new_bob = make_bot({ email: "bob@example.com", user_id: bob.user_id, full_name: "The Artist Formerly Known as Bob", - is_bot: true, - }; + }); const event = { type: "realm_user", diff --git a/web/tests/example5.test.js b/web/tests/example5.test.js index a7e7fa1393..ab5a7ff82c 100644 --- a/web/tests/example5.test.js +++ b/web/tests/example5.test.js @@ -2,6 +2,7 @@ const {strict: assert} = require("assert"); +const {make_user} = require("./lib/example_user"); const {mock_esm, zrequire} = require("./lib/namespace"); const {run_test, noop} = require("./lib/test"); @@ -46,11 +47,11 @@ const message_events = zrequire("message_events"); const message_store = zrequire("message_store"); const people = zrequire("people"); -const isaac = { +const isaac = make_user({ email: "isaac@example.com", user_id: 30, full_name: "Isaac Newton", -}; +}); people.add_active_user(isaac); /* diff --git a/web/tests/example8.test.js b/web/tests/example8.test.js index 6ec04f0930..fc1fa25208 100644 --- a/web/tests/example8.test.js +++ b/web/tests/example8.test.js @@ -2,6 +2,7 @@ const {strict: assert} = require("assert"); +const {make_user} = require("./lib/example_user"); const {mock_esm, zrequire} = require("./lib/namespace"); const {run_test} = require("./lib/test"); const $ = require("./lib/zjquery"); @@ -33,29 +34,29 @@ const typing_data = zrequire("typing_data"); const typing_events = zrequire("typing_events"); // Let us add a few users to use as typists. -const anna = { +const anna = make_user({ email: "anna@example.com", full_name: "Anna Karenina", user_id: 8, -}; +}); -const vronsky = { +const vronsky = make_user({ email: "vronsky@example.com", full_name: "Alexei Vronsky", user_id: 9, -}; +}); -const levin = { +const levin = make_user({ email: "levin@example.com", full_name: "Konstantin Levin", user_id: 10, -}; +}); -const kitty = { +const kitty = make_user({ email: "kitty@example.com", full_name: "Kitty S", user_id: 11, -}; +}); people.add_active_user(anna); people.add_active_user(vronsky);