2021-04-08 12:19:38 +03:00
|
|
|
import { expect } from 'chai'
|
2023-06-05 03:30:48 +03:00
|
|
|
import { describe, it } from 'mocha'
|
2021-04-08 12:19:38 +03:00
|
|
|
import { Readable } from 'stream'
|
2023-06-05 03:30:48 +03:00
|
|
|
|
2021-04-08 12:19:38 +03:00
|
|
|
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(
|
2023-06-05 03:30:48 +03:00
|
|
|
'aaeeffff33ee',
|
2021-04-08 12:19:38 +03:00
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|