Replace postForm() with postFormData() #62
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Because the Calculator module now supports multiple String Calculator implementations, there's no need for the main form to contain an action attribute. The default './add' URL is now defined as calculators.DEFAULT_ENDPOINT, and is referenced in the new calculators.defaultPost(). Calculator now ends up calling defaultPost(), with no need to know the POST URL.
As mentioned in the previous change, this will make it easy to add an implementation that talks to a separately running Tomcat backend eventually.
The core change wasn't very large and invasive, despite the apparent size of the commit. Several of the additional changes were basic housekeeping and refactorings that made sense to include at once.
Some of the additional changes and important details of the core change include:
Moves DocumentFragment + form comments from the deleted postForm() test into a new "Notes" section of strcalc/src/main/frontend/README.md.
Removes top-level
apiUrl
parameter, as the POST URL is now encapsulated in the calculator implementation function.Deletes the 'impl' field from the FormData produced by the input form, since it's irrelevant to the implementation. It will actually cause the Tomcat backend to return a server error if it's included.
Deletes the now unused resolvedUrl() test helper.
Moved test/helpers.js to test/page-loader.js, since that's the only entity left in that module.
Moved setupFetchStub() from request.test.js to test/fetch-stub.js to reuse it in the new calculators.test.js.