mtcute/packages/core/tests/stream-utils.spec.ts

21 lines
605 B
TypeScript
Raw Normal View History

2021-04-08 12:19:38 +03:00
import { describe, it } from 'mocha'
import { expect } from 'chai'
import { Readable } from 'stream'
import { readStreamUntilEnd } from '../src/utils/stream-utils'
describe('readStreamUntilEnd', () => {
it('should read stream until end', async () => {
const stream = new Readable({
read() {
this.push(Buffer.from('aaeeff', 'hex'))
this.push(Buffer.from('ff33ee', 'hex'))
this.push(null)
},
})
expect((await readStreamUntilEnd(stream)).toString('hex')).eq(
'aaeeffff33ee'
)
})
})