mirror of https://github.com/zulip/zulip.git
tests: Use `make_user` & `make_bot` to create test user & bot.
This commit is contained in:
parent
f9f2c32d21
commit
d6c34f64dd
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
||||
/*
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue