mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
node tests: Broaden what FakeComposeBox.reset does.
I moved some existing code into reset, as well as making sure a common banner has zero length.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {mock_banners} = require("./lib/compose_banner.cjs");
|
||||
const {FakeComposeBox} = require("./lib/compose_helpers.cjs");
|
||||
const {$t} = require("./lib/i18n.cjs");
|
||||
const {mock_esm, zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test, noop} = require("./lib/test.cjs");
|
||||
@@ -116,7 +117,11 @@ function stub_message_row($textarea) {
|
||||
}
|
||||
|
||||
test_ui("validate_stream_message_address_info", ({mock_template}) => {
|
||||
mock_banners();
|
||||
// For this test we basically only use FakeComposeBox
|
||||
// to set up the DOM environment. We don't assert about
|
||||
// any side effects on the DOM, since the scope of this
|
||||
// test is mostly to make sure the template gets rendered.
|
||||
new FakeComposeBox();
|
||||
|
||||
const party_sub = {
|
||||
stream_id: 101,
|
||||
@@ -128,7 +133,6 @@ test_ui("validate_stream_message_address_info", ({mock_template}) => {
|
||||
|
||||
party_sub.subscribed = false;
|
||||
stream_data.add_sub(party_sub);
|
||||
$("#compose_banners .user_not_subscribed").length = 0;
|
||||
let user_not_subscribed_rendered = false;
|
||||
mock_template("compose_banner/compose_banner.hbs", true, (data, html) => {
|
||||
assert.equal(data.classname, compose_banner.CLASSNAMES.user_not_subscribed);
|
||||
@@ -142,7 +146,9 @@ test_ui("validate_stream_message_address_info", ({mock_template}) => {
|
||||
party_sub.stream_id = 102;
|
||||
stream_data.add_sub(party_sub);
|
||||
user_not_subscribed_rendered = false;
|
||||
|
||||
assert.ok(!compose_validate.validate_stream_message_address_info(party_sub));
|
||||
|
||||
assert.ok(user_not_subscribed_rendered);
|
||||
});
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ class FakeComposeBox {
|
||||
".message-limit-indicator",
|
||||
$.create("limit-indicator-stub"),
|
||||
);
|
||||
$("textarea#compose-textarea").toggleClass = noop;
|
||||
|
||||
const $message_row_stub = $.create("message_row_stub");
|
||||
$("textarea#compose-textarea").closest = (selector) => {
|
||||
@@ -26,13 +25,15 @@ class FakeComposeBox {
|
||||
return $message_row_stub;
|
||||
};
|
||||
|
||||
$("textarea#compose-textarea").set_height(50);
|
||||
$("#compose .preview_message_area").css = noop;
|
||||
|
||||
this.reset();
|
||||
}
|
||||
|
||||
reset() {
|
||||
$("#compose_banners .user_not_subscribed").length = 0;
|
||||
|
||||
$("textarea#compose-textarea").toggleClass = noop;
|
||||
$("textarea#compose-textarea").set_height(50);
|
||||
$("#compose .preview_message_area").css = noop;
|
||||
$("textarea#compose-textarea").val("default message");
|
||||
$("textarea#compose-textarea").trigger("blur");
|
||||
$(".compose-submit-button .loader").show();
|
||||
|
||||
Reference in New Issue
Block a user