Skip to content

Commit bf777c4

Browse files
Remove fix, rebase to pick up Seb's fix, refactor test to use waitForMicrotasks
1 parent 58a09a3 commit bf777c4

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

packages/react-dom/src/__tests__/ReactDOMForm-test.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe('ReactDOMForm', () => {
3636
let Scheduler;
3737
let assertLog;
3838
let assertConsoleErrorDev;
39+
let waitForMicrotasks;
3940
let waitForThrow;
4041
let useState;
4142
let Suspense;
@@ -55,6 +56,7 @@ describe('ReactDOMForm', () => {
5556
Scheduler = require('scheduler');
5657
act = require('internal-test-utils').act;
5758
assertLog = require('internal-test-utils').assertLog;
59+
waitForMicrotasks = require('internal-test-utils').waitForMicrotasks;
5860
waitForThrow = require('internal-test-utils').waitForThrow;
5961
assertConsoleErrorDev =
6062
require('internal-test-utils').assertConsoleErrorDev;
@@ -1671,18 +1673,9 @@ describe('ReactDOMForm', () => {
16711673
});
16721674

16731675
it('multiple form submissions in rapid succession do not throw', async () => {
1674-
const submitFormTwiceButtonRef = React.createRef();
1676+
const formRef = React.createRef();
16751677
let actionCounter = 0;
16761678
function App() {
1677-
const formRef = React.createRef();
1678-
// Submits the form twice in quick succession
1679-
// This simulates a user clicking a button twice in rapid succession
1680-
async function submitFormTwice() {
1681-
formRef.current.requestSubmit();
1682-
await new Promise(res => setTimeout(res, 1));
1683-
formRef.current.requestSubmit();
1684-
}
1685-
16861679
// This is a userspace action. it must take a non-zero amount of time to
16871680
// allow the form to be submitted again before the first one finishes.
16881681
// Otherwise, the form transitions will be batched and will not run sepereately.
@@ -1696,9 +1689,6 @@ describe('ReactDOMForm', () => {
16961689
<form ref={formRef} action={submitForm}>
16971690
<button type="submit">Submit</button>
16981691
</form>
1699-
<button ref={submitFormTwiceButtonRef} onClick={submitFormTwice}>
1700-
Submit twice
1701-
</button>
17021692
</>
17031693
);
17041694
}
@@ -1707,7 +1697,9 @@ describe('ReactDOMForm', () => {
17071697
await act(() => root.render(<App />));
17081698

17091699
await act(async () => {
1710-
submitFormTwiceButtonRef.current.click();
1700+
formRef.current.requestSubmit();
1701+
await waitForMicrotasks();
1702+
formRef.current.requestSubmit();
17111703
});
17121704
expect(actionCounter).toBe(2);
17131705
});

0 commit comments

Comments
 (0)