feat(response): Add streamNode() method for Node.js stream support; update tests
This commit is contained in:
27
test/test.streamnode.ts
Normal file
27
test/test.streamnode.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||
import { SmartRequest } from '../ts/index.js';
|
||||
|
||||
tap.test('should have streamNode() method available', async () => {
|
||||
const response = await SmartRequest.create()
|
||||
.url('https://httpbin.org/get')
|
||||
.get();
|
||||
|
||||
// Verify streamNode() method exists
|
||||
expect(response.streamNode).toBeDefined();
|
||||
expect(typeof response.streamNode).toEqual('function');
|
||||
|
||||
// In Node.js, it should return a stream
|
||||
const nodeStream = response.streamNode();
|
||||
expect(nodeStream).toBeDefined();
|
||||
|
||||
// Verify it's a Node.js readable stream
|
||||
expect(typeof nodeStream.pipe).toEqual('function');
|
||||
expect(typeof nodeStream.on).toEqual('function');
|
||||
|
||||
// Consume the stream to avoid hanging
|
||||
nodeStream.resume();
|
||||
});
|
||||
|
||||
|
||||
|
||||
export default tap.start();
|
Reference in New Issue
Block a user