busboy
busboy copied to clipboard
Improve test coverage
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 ofcharset - Supposing we change from an arrow function to a function, I don't see how the
ifstatement 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.- In order to not enter the
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 } - In order to enter this last
if,this._checkingBytesmust befalse, which happens at line 112, which is inside anelse if (this._hitLimit) - Thus, I need
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 tolen - For what concern line 164, the reasoning is basically the same, since the only difference is that, for line 164, we are working on the parameter value, while for line 118 we are working for the parameter name
- In order to not enter the
Of 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
- [x] run
npm run testandnpm run benchmark - [x] tests and/or benchmarks are included
- [ ] documentation is changed or added
- [x] commit message and code follows the Developer's Certification of Origin and the Code of conduct