diff --git a/spec/javascripts/stimulus/toggle_control_controller_test.js b/spec/javascripts/stimulus/toggle_control_controller_test.js index dca6e3df0e..12746389e7 100644 --- a/spec/javascripts/stimulus/toggle_control_controller_test.js +++ b/spec/javascripts/stimulus/toggle_control_controller_test.js @@ -71,11 +71,12 @@ describe("ToggleControlController", () => { `; }); - it("Enables when input is filled", () => { + it("Enables when input is filled and focuses the control", () => { input.value = "a" input.dispatchEvent(new Event("input")); expect(control.disabled).toBe(false); + expect(document.activeElement).toBe(control); }); it("Disables when input is emptied", () => { @@ -88,6 +89,37 @@ describe("ToggleControlController", () => { expect(control.disabled).toBe(true); }); }); + describe("with button as control target", () => { + beforeEach(() => { + document.body.innerHTML = `