node tests: Use set_find_results in stream_edit test.

This commit is contained in:
Steve Howell 2021-12-22 13:28:40 +00:00 committed by Tim Abbott
parent 507da749b7
commit 0574d951e4
2 changed files with 15 additions and 30 deletions

View File

@ -145,38 +145,18 @@ test_ui("subscriber_pills", ({override, mock_template}) => {
const $sub_settings_container = $.create(sub_settings_selector);
const $edit_subscribers_container = $.create("edit-subscribers-stub");
const $unused = $.create("unused");
$sub_settings_container.find = (selector) => {
switch (selector) {
case ".colorpicker": {
return undefined;
}
case ".edit_subscribers_for_stream": {
return $edit_subscribers_container;
}
// No default
}
throw new Error(`unexpected selector ${selector}`);
};
$sub_settings_container.set_find_results(".colorpicker", $unused);
$sub_settings_container.set_find_results(
".edit_subscribers_for_stream",
$edit_subscribers_container,
);
$edit_subscribers_container.find = (selector) => {
switch (selector) {
case ".pill-container": {
return pill_container_stub;
}
case ".search": {
return undefined;
}
case ".subscriber_table": {
return $.create("subscriber-table-stub");
}
case ".subscriber_list_container": {
return undefined;
}
// No default
}
throw new Error(`unexpected selector ${selector}`);
};
$edit_subscribers_container.set_find_results(".pill-container", pill_container_stub);
$edit_subscribers_container.set_find_results(".search", $unused);
$edit_subscribers_container.set_find_results(".subscriber_table", $unused);
$edit_subscribers_container.set_find_results(".subscriber_list_container", $unused);
const $subscription_settings = $.create(".subscription_settings");
$subscription_settings.addClass = noop;

View File

@ -202,6 +202,11 @@ function FakeElement(selector, opts) {
return self;
},
set_find_results(find_selector, jquery_object) {
if (jquery_object === undefined) {
throw new Error(
"Please make the 'find result' be something like $.create('unused')",
);
}
find_results.set(find_selector, jquery_object);
},
set_height(fake_height) {