import { expect, tap } from '@push.rocks/tapbundle'; import { SmartStream } from '../ts/smartstream.classes.smartstream.js'; // Adjust the import to your file structure import * as smartrx from '@push.rocks/smartrx'; import * as fs from 'fs'; tap.test('should create a SmartStream from a Buffer', async () => { const bufferData = Buffer.from('This is a test buffer'); const smartStream = SmartStream.fromBuffer(bufferData); let receivedData = Buffer.alloc(0); return new Promise((resolve) => { smartStream.on('data', (chunk: Buffer) => { receivedData = Buffer.concat([receivedData, chunk]); }); smartStream.on('end', () => { expect(receivedData.toString()).toEqual(bufferData.toString()); resolve(); }); }); }); tap.test('should create a SmartStream from an Observable', async () => { const observableData = 'Observable test data'; const testObservable = smartrx.rxjs.of(Buffer.from(observableData)); const smartStream = SmartStream.fromObservable(testObservable); let receivedData = Buffer.alloc(0); return new Promise((resolve) => { smartStream.on('data', (chunk: Buffer) => { receivedData = Buffer.concat([receivedData, chunk]); }); smartStream.on('end', () => { expect(receivedData.toString()).toEqual(observableData); resolve(); }); }); }); tap.start();