mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Create function to wrap streams to not lose errors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { PassThrough } from 'stream';
|
||||
import streamifyArray from 'streamify-array';
|
||||
import { pipeSafely, readableToString } from '../../../src/util/StreamUtil';
|
||||
import { guardedStreamFrom, pipeSafely, readableToString } from '../../../src/util/StreamUtil';
|
||||
|
||||
describe('StreamUtil', (): void => {
|
||||
describe('#readableToString', (): void => {
|
||||
@@ -40,4 +40,11 @@ describe('StreamUtil', (): void => {
|
||||
await expect(readableToString(piped)).rejects.toThrow(new Error('other error'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#guardedStreamFrom', (): void => {
|
||||
it('converts data to a guarded stream.', async(): Promise<void> => {
|
||||
const data = [ 'a', 'b' ];
|
||||
await expect(readableToString(guardedStreamFrom(data))).resolves.toBe('ab');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user