mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2025-12-31 15:02:19 +00:00
improve stream testing
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
This commit is contained in:
parent
6951ef3b10
commit
e09aa99a0d
1 changed files with 6 additions and 2 deletions
|
|
@ -6,12 +6,16 @@
|
|||
const OutputListener = require('../lib/output-listener');
|
||||
const { PassThrough } = require('stream');
|
||||
describe('output-listener', () => {
|
||||
it('receives and exposes data', () => {
|
||||
const listener = new OutputListener(new PassThrough());
|
||||
it('receives and exposes data', () => {
|
||||
const stream = new PassThrough();
|
||||
const listener = new OutputListener(stream);
|
||||
const listen = listener.listener;
|
||||
listen(Buffer.from('foo'));
|
||||
expect(stream.read()).toEqual(Buffer.from('foo'));
|
||||
listen(Buffer.from('bar'));
|
||||
expect(stream.read()).toEqual(Buffer.from('bar'));
|
||||
listen(Buffer.from('baz'));
|
||||
expect(stream.read()).toEqual(Buffer.from('baz'));
|
||||
expect(listener.contents).toEqual('foobarbaz');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue