preventing users from double click on submit

This commit is contained in:
Beverly Nguyen
2025-03-13 15:04:12 -07:00
parent ff65471084
commit 821265cf6e
7 changed files with 32 additions and 14 deletions

View File

@@ -44,20 +44,19 @@ describe('Prevent duplicate form submissions', () => {
});
test("It should prevent any clicks of the 'submit' button after the first one submitting the form", () => {
test("It should prevent the second click on the 'submit' button", () => {
helpers.triggerEvent(button, 'click');
expect(button.disabled).toBe(true);
helpers.triggerEvent(button, 'click');
expect(formEventSpy.mock.calls.length).toEqual(1);
expect(button.disabled).toBe(true);
});
test("It should allow clicks again after 1.5 seconds", () => {
helpers.triggerEvent(button, 'click');
jest.advanceTimersByTime(1500);
jest.advanceTimersByTime(10000);
helpers.triggerEvent(button, 'click');