mirror of https://github.com/zulip/zulip.git
zjquery: Remove bogus remove().
This commit is contained in:
parent
bd034f5767
commit
5437a16602
|
@ -517,6 +517,11 @@ test_ui("insert_fred_then_alice_then_rename", (override) => {
|
|||
inserted_html = html;
|
||||
};
|
||||
|
||||
let fred_removed;
|
||||
fred_stub.remove = () => {
|
||||
fred_removed = true;
|
||||
};
|
||||
|
||||
activity.redraw_user(alice.user_id);
|
||||
assert(inserted_html.indexOf('data-user-id="1"') > 0);
|
||||
assert(inserted_html.indexOf("user_circle_green") > 0);
|
||||
|
@ -537,6 +542,7 @@ test_ui("insert_fred_then_alice_then_rename", (override) => {
|
|||
};
|
||||
|
||||
activity.redraw_user(fred_with_new_name.user_id);
|
||||
assert(fred_removed);
|
||||
assert(appended_html.indexOf('data-user-id="2"') > 0);
|
||||
|
||||
// restore old Fred data
|
||||
|
|
|
@ -26,6 +26,8 @@ run_test("render_alert_words_ui", () => {
|
|||
const alert_word_items = $.create("alert_word_items");
|
||||
word_list.set_find_results(".alert-word-item", alert_word_items);
|
||||
|
||||
alert_word_items.remove = () => {};
|
||||
|
||||
stub_templates((name, args) => {
|
||||
assert.equal(name, "settings/alert_word_settings_item");
|
||||
return "stub-" + args.word;
|
||||
|
|
|
@ -32,6 +32,11 @@ run_test("copy_data_attribute_value", (override) => {
|
|||
|
||||
const input = $.create("input");
|
||||
|
||||
let removed;
|
||||
input.remove = () => {
|
||||
removed = true;
|
||||
};
|
||||
|
||||
override(document, "createElement", () => input);
|
||||
override(document, "execCommand", noop);
|
||||
|
||||
|
@ -60,6 +65,7 @@ run_test("copy_data_attribute_value", (override) => {
|
|||
faded_in = true;
|
||||
};
|
||||
common.copy_data_attribute_value(elem, "admin-emails");
|
||||
assert(removed);
|
||||
assert(faded_in);
|
||||
assert(faded_out);
|
||||
});
|
||||
|
|
|
@ -314,7 +314,7 @@ test_ui("validate", () => {
|
|||
assert.equal($("#compose-error-msg").html(), i18n.t("Please specify a topic"));
|
||||
});
|
||||
|
||||
test_ui("get_invalid_recipient_emails", () => {
|
||||
test_ui("get_invalid_recipient_emails", (override) => {
|
||||
const welcome_bot = {
|
||||
email: "welcome-bot@example.com",
|
||||
user_id: 124,
|
||||
|
@ -330,7 +330,7 @@ test_ui("get_invalid_recipient_emails", () => {
|
|||
|
||||
people.initialize(page_params.user_id, params);
|
||||
|
||||
compose_state.private_message_recipient("welcome-bot@example.com");
|
||||
override(compose_state, "private_message_recipient", () => "welcome-bot@example.com");
|
||||
assert.deepEqual(compose.get_invalid_recipient_emails(), []);
|
||||
});
|
||||
|
||||
|
|
|
@ -403,6 +403,18 @@ run_test("insert_remove", () => {
|
|||
assert.equal(pill_input.text(), "");
|
||||
assert.equal(widget.is_pending(), false);
|
||||
|
||||
let color_removed;
|
||||
function set_colored_removed_func(color) {
|
||||
return () => {
|
||||
color_removed = color;
|
||||
};
|
||||
}
|
||||
|
||||
const pills = widget._get_pills_for_testing();
|
||||
for (const pill of pills) {
|
||||
pill.$element.remove = set_colored_removed_func(pill.item.display_value);
|
||||
}
|
||||
|
||||
const BACKSPACE = 8;
|
||||
let key_handler = container.get_on_handler("keydown", ".input");
|
||||
|
||||
|
@ -415,6 +427,7 @@ run_test("insert_remove", () => {
|
|||
});
|
||||
|
||||
assert(removed);
|
||||
assert.equal(color_removed, "YELLOW");
|
||||
|
||||
assert.deepEqual(widget.items(), [items.blue, items.red]);
|
||||
|
||||
|
@ -444,6 +457,7 @@ run_test("insert_remove", () => {
|
|||
preventDefault: noop,
|
||||
});
|
||||
|
||||
assert.equal(color_removed, "BLUE");
|
||||
assert(next_pill_focused);
|
||||
});
|
||||
|
||||
|
@ -458,6 +472,11 @@ run_test("exit button on pill", () => {
|
|||
|
||||
widget.appendValue("blue,red");
|
||||
|
||||
const pills = widget._get_pills_for_testing();
|
||||
for (const pill of pills) {
|
||||
pill.$element.remove = () => {};
|
||||
}
|
||||
|
||||
let next_pill_focused = false;
|
||||
|
||||
const next_pill_stub = {
|
||||
|
|
|
@ -56,6 +56,8 @@ run_test("settings", () => {
|
|||
return topic_tr_html;
|
||||
};
|
||||
|
||||
topic_tr_html.remove = () => {};
|
||||
|
||||
let topic_data_called = 0;
|
||||
topic_tr_html.attr = (opts) => {
|
||||
if (opts === "data-stream-id") {
|
||||
|
|
|
@ -99,7 +99,9 @@ run_test("unloaded", () => {
|
|||
});
|
||||
|
||||
function simulate_realm_domains_table() {
|
||||
$("#realm_domains_table tbody").set_find_results("tr", $.create("realm-tr-stub"));
|
||||
const tr_stub = $.create("realm-tr-stub");
|
||||
$("#realm_domains_table tbody").set_find_results("tr", tr_stub);
|
||||
tr_stub.remove = () => {};
|
||||
|
||||
let appended;
|
||||
$("#realm_domains_table tbody").append = (html) => {
|
||||
|
|
|
@ -54,6 +54,9 @@ function test_populate(opts) {
|
|||
|
||||
table[0] = "stub";
|
||||
|
||||
rows.remove = () => {};
|
||||
form.remove = () => {};
|
||||
|
||||
let num_appends = 0;
|
||||
table.append = () => {
|
||||
num_appends += 1;
|
||||
|
|
|
@ -22,6 +22,7 @@ const get_spoiler_elem = (title) => {
|
|||
const block = $.create(`block-${title}`);
|
||||
const header = $.create(`header-${title}`);
|
||||
const content = $.create(`content-${title}`);
|
||||
content.remove = () => {};
|
||||
header.text(title);
|
||||
block.set_find_results(".spoiler-header", header);
|
||||
block.set_find_results(".spoiler-content", content);
|
||||
|
|
|
@ -342,7 +342,14 @@ function make_new_elem(selector, opts) {
|
|||
return self;
|
||||
},
|
||||
remove() {
|
||||
return self;
|
||||
throw new Error(`
|
||||
We don't support remove in zjuery.
|
||||
|
||||
You can do $(...).remove = ... if necessary.
|
||||
|
||||
But you are probably writing too deep a test
|
||||
for node testing.
|
||||
`);
|
||||
},
|
||||
removeData: noop,
|
||||
replaceWith() {
|
||||
|
|
Loading…
Reference in New Issue