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.
As mentioned in #77, tests/test.html appears to have been left behind and currently neither works nor tests the current code. There are automated tests now, which is certainly better, but their coverage is limited, so I think the examples in test.html are still useful as additional manual regression tests. This commit revives them.
Fixing the “works” part required:
$.get()
call that does not seem to automatically decode JSON when it's coming from a file:https:// URL.To fix the “test the current code” part, it replaces the outdated public/docson.js by public/js/docson.js that is built from current sources: A script that can be loaded in the browser and exports the docson API as a global variable. (It also exports the bundled jQuery as a convenience to test.html that uses it, so it doesn’t have to bring its own copy, but if there is a better solution for that, src/index.js could also be webpacked directly.) Note that I’m not familiar with webpack and may be using it wrong, I just did what appears to work.
As an alternative solution, I first tried using widget.js, but gave up after hitting several obstacles: #73, it wouldn’t work when the
<script>
tags were generated by code rather than present in static HTML (apparentlydocument.write()
has no effect then), and the many iframes just looked messy.The commit also removes public/lib/ that is not used by anything anymore.
I’m not sure what to do about the new generated file public/js/docson.js (as well as lib/docson.browser.js, which occured as a byproduct and is probably useless): My usual solution would be to add it to .gitignore, but then other generated files are committed and appear to be updated occasionally in a separate commit before a release, so I left it alone.
This reveals several deficiencies compared to http:https://lbovet.github.io/docson/tests/test.html, I will try to fix some of them in subsequent pull requests to make the tests useful again for regression-testing my own changes.