diff --git a/frontend_tests/node_tests/settings_profile_fields.js b/frontend_tests/node_tests/settings_profile_fields.js index 85b517a6a6..ea789a70df 100644 --- a/frontend_tests/node_tests/settings_profile_fields.js +++ b/frontend_tests/node_tests/settings_profile_fields.js @@ -37,6 +37,8 @@ page_params.custom_profile_field_types = { }, }; +mock_esm("sortablejs", {Sortable: {create: () => {}}}); + const settings_profile_fields = zrequire("settings_profile_fields"); function test_populate(opts) { @@ -74,8 +76,7 @@ function test_populate(opts) { assert.equal(num_appends, fields_data.length); } -run_test("populate_profile_fields", (override) => { - override(settings_profile_fields, "create_sortable", () => {}); +run_test("populate_profile_fields", () => { const fields_data = [ { type: SHORT_TEXT_ID, diff --git a/static/js/settings_profile_fields.js b/static/js/settings_profile_fields.js index 3f3a932b13..a8b07d8006 100644 --- a/static/js/settings_profile_fields.js +++ b/static/js/settings_profile_fields.js @@ -11,12 +11,6 @@ const meta = { loaded: false, }; -export function create_sortable(...opts) { - // This function is extracted so tests can easily - // stub Sortable. - return Sortable.create(...opts); -} - export function maybe_disable_widgets() { if (page_params.is_admin) { return; @@ -271,7 +265,7 @@ function set_up_choices_field_edit_form(profile_field, field_data) { // Add blank choice at last create_choice_row(choice_list); update_choice_delete_btn(choice_list, false); - create_sortable(choice_list[0], { + Sortable.create(choice_list[0], { onUpdate() {}, }); } @@ -410,7 +404,7 @@ export function do_populate_profile_fields(profile_fields_data) { if (page_params.is_admin) { const field_list = $("#admin_profile_fields_table")[0]; - create_sortable(field_list, { + Sortable.create(field_list, { onUpdate: update_field_order, }); } @@ -425,7 +419,7 @@ function set_up_choices_field() { if (page_params.is_admin) { const choice_list = $("#profile_field_choices")[0]; - create_sortable(choice_list, { + Sortable.create(choice_list, { onUpdate() {}, }); }