WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 08aa4a2

Browse files
authored
Merge pull request #23 from taketo1113/export-reset-disable
Add resetDisable method to exports
2 parents 3ca5ce7 + 486e0d2 commit 08aa4a2

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

src/disable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ const resetDisableEvent = function () {
4545
});
4646
};
4747

48-
export default { start };
48+
export default { start, resetDisableEvent };

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ const startDisable = function () {
2929
loadState.setLoaded(moduleName);
3030
};
3131

32+
const resetDisable = function () {
33+
disable.resetDisableEvent();
34+
};
35+
3236
const startMethod = function () {
3337
const moduleName = "method";
3438
loadState.checkLoaded(moduleName);
@@ -39,4 +43,4 @@ const startMethod = function () {
3943
loadState.setLoaded(moduleName);
4044
};
4145

42-
export default { start, startConfirm, startDisable, startMethod };
46+
export default { start, startConfirm, startDisable, resetDisable, startMethod };

test/disable.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect, test, beforeEach, afterEach } from "vitest";
22
import userEvent from "@testing-library/user-event";
3-
import { setDisableFormEvents } from "../src/disable.js";
3+
import disable, { setDisableFormEvents } from "../src/disable.js";
44

55
let calledSubmit = false;
66

@@ -58,3 +58,17 @@ test("disable the form submit button when entering input element", async () => {
5858
const elementSubmit = document.getElementById("id-submit");
5959
expect(elementSubmit.disabled).toBe(true);
6060
});
61+
62+
test("reset disable event", async () => {
63+
// prepare
64+
const element = document.getElementById("id-submit");
65+
const user = userEvent.setup();
66+
await user.click(element);
67+
const elementSubmit = document.getElementById("id-submit");
68+
expect(elementSubmit.disabled).toBe(true);
69+
70+
disable.resetDisableEvent();
71+
72+
// assert
73+
expect(elementSubmit.disabled).toBe(false);
74+
});

test/index.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ describe("#startDisable", () => {
4747
});
4848
});
4949

50+
describe("#resetDisable", () => {
51+
test("export resetDisable", () => {
52+
expect(AltUjs.resetDisable()).not.toBeNull();
53+
});
54+
});
55+
5056
describe("#startMethod", () => {
5157
test("export startMethod", () => {
5258
expect(AltUjs.startMethod).not.toBeNull();

0 commit comments

Comments
 (0)