From 994dd606b9773df9c5a9f23a1907025875dd3c3f Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 24 Nov 2023 14:08:51 +1100 Subject: [PATCH] Refactor: remove dead code I was mistakenly thinking that you can define variables in beforeEach, but it turns out these are not used. Rather, Jest was automatically creating variables for the elements according to their IDs. How convenient! --- .../stimulus/bulk_form_controller_test.js | 12 +----------- spec/javascripts/stimulus/popout_controller_test.js | 6 ------ .../stimulus/toggle_control_controller_test.js | 6 ------ 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/spec/javascripts/stimulus/bulk_form_controller_test.js b/spec/javascripts/stimulus/bulk_form_controller_test.js index a1f0ee6250..b0a3386ce9 100644 --- a/spec/javascripts/stimulus/bulk_form_controller_test.js +++ b/spec/javascripts/stimulus/bulk_form_controller_test.js @@ -36,7 +36,7 @@ describe("BulkFormController", () => {
- +
@@ -44,16 +44,6 @@ describe("BulkFormController", () => { `; - - const disable1 = document.getElementById("disable1"); - const disable1_element = document.getElementById("disable1_element"); - const disable2 = document.getElementById("disable2"); - const disable2_element = document.getElementById("disable2_element"); - const actions = document.getElementById("actions"); - const changed_summary = document.getElementById("changed_summary"); - const input1a = document.getElementById("input1a"); - const input1b = document.getElementById("input1b"); - const input2 = document.getElementById("input2"); }); describe("marking changed fields", () => { diff --git a/spec/javascripts/stimulus/popout_controller_test.js b/spec/javascripts/stimulus/popout_controller_test.js index 91f62e7ec5..60b6f8ce89 100644 --- a/spec/javascripts/stimulus/popout_controller_test.js +++ b/spec/javascripts/stimulus/popout_controller_test.js @@ -26,12 +26,6 @@ describe("PopoutController", () => {
`; - - const button = document.getElementById("button"); - const input1 = document.getElementById("input1"); - const input2 = document.getElementById("input2"); - const input3 = document.getElementById("input3"); - const input4 = document.getElementById("input4"); }); describe("Show", () => { diff --git a/spec/javascripts/stimulus/toggle_control_controller_test.js b/spec/javascripts/stimulus/toggle_control_controller_test.js index eeffc17ae6..f56686fe9d 100644 --- a/spec/javascripts/stimulus/toggle_control_controller_test.js +++ b/spec/javascripts/stimulus/toggle_control_controller_test.js @@ -18,9 +18,6 @@ describe("ToggleControlController", () => { `; - - const checkbox = document.getElementById("checkbox"); - const control = document.getElementById("control"); }); it("Disables when checkbox is checked", () => { @@ -44,9 +41,6 @@ describe("ToggleControlController", () => { `; - - const input = document.getElementById("input"); - const control = document.getElementById("control"); }); it("Disables when input is filled", () => {