2021-03-05 16:57:23 +01:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2021-03-10 06:10:32 +01:00
|
|
|
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
2021-03-05 16:57:23 +01:00
|
|
|
const {run_test} = require("../zjsunit/test");
|
|
|
|
|
2021-03-10 06:10:32 +01:00
|
|
|
const compose_pm_pill = mock_esm("../../static/js/compose_pm_pill");
|
2021-03-05 16:57:23 +01:00
|
|
|
|
|
|
|
const compose_state = zrequire("compose_state");
|
|
|
|
|
2021-06-16 14:38:37 +02:00
|
|
|
run_test("private_message_recipient", ({override}) => {
|
2021-03-05 16:57:23 +01:00
|
|
|
let emails;
|
|
|
|
override(compose_pm_pill, "set_from_emails", (value) => {
|
|
|
|
emails = value;
|
|
|
|
});
|
|
|
|
|
|
|
|
override(compose_pm_pill, "get_emails", () => emails);
|
|
|
|
|
|
|
|
compose_state.private_message_recipient("fred@fred.org");
|
|
|
|
assert.equal(compose_state.private_message_recipient(), "fred@fred.org");
|
|
|
|
});
|
2022-03-09 18:29:01 +01:00
|
|
|
|
2022-09-26 21:01:43 +02:00
|
|
|
run_test("has_full_recipient", ({override}) => {
|
|
|
|
let emails;
|
|
|
|
override(compose_pm_pill, "set_from_emails", (value) => {
|
|
|
|
emails = value;
|
|
|
|
});
|
|
|
|
|
|
|
|
override(compose_pm_pill, "get_emails", () => emails);
|
|
|
|
|
|
|
|
compose_state.set_message_type("stream");
|
2022-10-27 00:22:29 +02:00
|
|
|
compose_state.set_stream_name("");
|
2022-03-09 18:29:01 +01:00
|
|
|
compose_state.topic("");
|
2022-09-26 21:01:43 +02:00
|
|
|
assert.equal(compose_state.has_full_recipient(), false);
|
2022-03-09 18:29:01 +01:00
|
|
|
|
|
|
|
compose_state.topic("foo");
|
2022-09-26 21:01:43 +02:00
|
|
|
assert.equal(compose_state.has_full_recipient(), false);
|
|
|
|
|
2022-10-27 00:22:29 +02:00
|
|
|
compose_state.set_stream_name("bar");
|
2022-09-26 21:01:43 +02:00
|
|
|
assert.equal(compose_state.has_full_recipient(), true);
|
|
|
|
|
|
|
|
compose_state.set_message_type("private");
|
|
|
|
compose_state.private_message_recipient("");
|
|
|
|
assert.equal(compose_state.has_full_recipient(), false);
|
|
|
|
|
|
|
|
compose_state.private_message_recipient("foo@zulip.com");
|
|
|
|
assert.equal(compose_state.has_full_recipient(), true);
|
2022-03-09 18:29:01 +01:00
|
|
|
});
|