| 884 | |
| 885 | describe('#write', () => { |
| 886 | const createStream = (chunks?: Buffer[]): PassThrough => { |
| 887 | chunks = chunks ?? randUnique({ length: randNumber({ min: 1, max: 10 }) }).map((str: string) => Buffer.from(str)); |
| 888 | |
| 889 | const stream = new PassThrough(); |
| 890 | |
| 891 | for (const chunk of chunks!) { |
| 892 | stream.emit('data', chunk); |
| 893 | } |
| 894 | |
| 895 | stream.end(); |
| 896 | stream.destroy(); |
| 897 | |
| 898 | return stream; |
| 899 | }; |
| 900 | |
| 901 | // NOTE: Blob's can't be converted to Strings by `vitest`, so any `.toEqual()` or |
| 902 | // `.hasBeenCalledWith` uses against the params of the function call will error with a |