diff --git a/__tests__/s3/formatters.test.ts b/__tests__/s3/formatters.test.ts new file mode 100644 index 0000000..50cb6e1 --- /dev/null +++ b/__tests__/s3/formatters.test.ts @@ -0,0 +1,30 @@ +import { streamToString } from '../../src/s3' +import stream from 'stream' + +describe('streamToString', () => { + it('should convert a stream to a string', async () => { + const readable = new stream.Readable() + + readable._read = () => {} + readable.push('Hello, ') + readable.push('world!') + readable.push(null) + + const result = await streamToString(readable) + expect(result).toEqual('Hello, world!') + }) + + it('should convert a JSON stream to a string', async () => { + const json = { name: 'John Doe', age: 30 } + const jsonString = JSON.stringify(json) + const readable = new stream.Readable() + + readable._read = () => {} + readable.push(jsonString) + + const result = await streamToString(readable) + expect(result).toEqual(jsonString) + }) + + +}) diff --git a/src/s3/index.ts b/src/s3/index.ts index 25653d3..32901d8 100644 --- a/src/s3/index.ts +++ b/src/s3/index.ts @@ -1,2 +1,2 @@ export * from './s3Service' - +export * from './formatters'