import { expect, tap } from '@git.zone/tstest/tapbundle'; import * as smartshell from '../ts/index.js'; tap.test('should send input to cat command', async (tools) => { const testSmartshell = new smartshell.Smartshell({ executor: 'bash', sourceFilePaths: [], }); // Use cat which simply echoes what it receives const interactive = await testSmartshell.execInteractiveControl('cat'); // Send some text and close stdin await interactive.sendLine('Hello World'); interactive.endInput(); // Close stdin properly const result = await interactive.finalPromise; expect(result.exitCode).toEqual(0); expect(result.stdout).toContain('Hello World'); }); tap.test('should work with simple echo', async () => { const testSmartshell = new smartshell.Smartshell({ executor: 'bash', sourceFilePaths: [], }); // This should work without any input const interactive = await testSmartshell.execInteractiveControl('echo "Direct test"'); const result = await interactive.finalPromise; expect(result.exitCode).toEqual(0); expect(result.stdout).toContain('Direct test'); }); tap.test('should handle streaming with input control', async (tools) => { const testSmartshell = new smartshell.Smartshell({ executor: 'bash', sourceFilePaths: [], }); // Test with streaming and cat const streaming = await testSmartshell.execStreamingInteractiveControl('cat'); await streaming.sendLine('Line 1'); await streaming.sendLine('Line 2'); streaming.endInput(); // Close stdin const result = await streaming.finalPromise; expect(result.exitCode).toEqual(0); expect(result.stdout).toContain('Line 1'); expect(result.stdout).toContain('Line 2'); }); export default tap.start();