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.js
still misses line 97 and 98. Though, I'm not sure they will ever be hit:-
this
keyword 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 thethis
inside 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
if
statement at line 96 will pass: we ask if thetextDecoders
has the givencharset
, wheretextDecoders
includesutf-8
andutf8
. But, if thecharset
passed at line 42 is one of the two values, then another branch of theswitch
statement is taken.
-
-
urlencoded.js
still misses line 118 and 164, but again, I'm not sure that they will ever be hit.- In order to not enter the
if
statement at line 118,p
needs to be higher thanlen
, and the only way I figured out is the loopfor
at line 58, where inside at line 59 we haveif (!this._checkingBytes) { ++p }
- In order to enter this last
if
,this._checkingBytes
must befalse
, which happens at line 112, which is inside anelse if (this._hitLimit)
- Thus, I need
this._hitlimit
equals totrue
, but.. If that happens, since thatif else
statement is before the lastelse
at line 117 which leads to line 118, the line 118 cannot be reached withp
being 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 test
andnpm 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