Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test to s3 formatter #252

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions __tests__/s3/formatters.test.ts
Original file line number Diff line number Diff line change
@@ -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)
})


})
2 changes: 1 addition & 1 deletion src/s3/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './s3Service'

export * from './formatters'
Loading