Fixes the exception from the failing test ``` 1) multipart Parser for an empty text file upload "before each" hook: TypeError: Cannot call method 'end' of undefined at File.end (/Users/barczewskij/projects/strata/lib/multipart/file.js:48:21) at Part.Parser.onPart.content (/Users/barczewskij/projects/strata/lib/multipart/parser.js:380:12) at Part.EventEmitter.emit (events.js:93:17) at Part.end (/Users/barczewskij/projects/strata/lib/multipart/part.js:69:8) ```
as well as a string by checking for optional env.mockReturnsBuffer = true Also when collecting stream data, need to use Buffer.concat since even utf8 data can be divided over chunk boundaries and result in bad concatenation. Buffer.concat is the best way to ensure this will not cause a problem.
mock.call should support a binary stream and return a Buffer, but since originally this was returning body as a string, this can be made optional. Pass env.mockReturnsBuffer = true to keep body being returned as a Buffer rather than converting to a string. Buffer.concat needs to be used rather than trying to combine Buffers as strings since even utf8 can break across chunk boundaries.