Improve test coverage #153
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.
To help obtain 100% coverage from #126, I've added few tests. Also, few comments on some files that are still not 100% covered:
decodeText.jsstill misses line 97 and 98. Though, I'm not sure they will ever be hit:thiskeyword at line 96 is used, but the method is an arrow function which is called viabind(charset)from line 42; though, I'm afraid that, being an arrow function, the scope of thethisinside of it will not be the passed value ofcharsetifstatement at line 96 will pass: we ask if thetextDecodershas the givencharset, wheretextDecodersincludesutf-8andutf8. But, if thecharsetpassed at line 42 is one of the two values, then another branch of theswitchstatement is taken.urlencoded.jsstill misses line 118 and 164, but again, I'm not sure that they will ever be hit.ifstatement at line 118,pneeds to be higher thanlen, and the only way I figured out is the loopforat line 58, where inside at line 59 we haveif (!this._checkingBytes) { ++p }if,this._checkingBytesmust befalse, which happens at line 112, which is inside anelse if (this._hitLimit)this._hitlimitequals totrue, but.. If that happens, since thatif elsestatement is before the lastelseat line 117 which leads to line 118, the line 118 cannot be reached withpbeing greater or equals tolenOf course, I may be wrong for both files: I tried to go through all the code and understanding it, but maybe I'm missing some pieces.
Checklist
npm run testandnpm run benchmarkand the Code of conduct