(submitter)
| 185 | }); |
| 186 | |
| 187 | async function submit(submitter) { |
| 188 | await act(() => { |
| 189 | const form = submitter.form || submitter; |
| 190 | if (!submitter.form) { |
| 191 | submitter = undefined; |
| 192 | } |
| 193 | const submitEvent = new Event('submit', { |
| 194 | bubbles: true, |
| 195 | cancelable: true, |
| 196 | }); |
| 197 | submitEvent.submitter = submitter; |
| 198 | const returnValue = form.dispatchEvent(submitEvent); |
| 199 | if (!returnValue) { |
| 200 | return; |
| 201 | } |
| 202 | const action = |
| 203 | (submitter && submitter.getAttribute('formaction')) || form.action; |
| 204 | if (!/\s*javascript:/i.test(action)) { |
| 205 | throw new Error('Navigate to: ' + action); |
| 206 | } |
| 207 | }); |
| 208 | } |
| 209 | |
| 210 | it('should allow passing a function to form action', async () => { |
| 211 | const ref = React.createRef(); |
no test coverage detected