@@ -7,13 +7,24 @@ import { TerminalProcess } from "../TerminalProcess"
77import { Terminal } from "../Terminal"
88import { TerminalRegistry } from "../TerminalRegistry"
99
10+ class TestTerminalProcess extends TerminalProcess {
11+ public callTrimRetrievedOutput ( ) : void {
12+ this . trimRetrievedOutput ( )
13+ }
14+ }
15+
1016vi . mock ( "execa" , ( ) => ( {
1117 execa : vi . fn ( ) ,
1218} ) )
1319
1420describe ( "TerminalProcess" , ( ) => {
15- let terminalProcess : TerminalProcess
21+ let terminalProcess : TestTerminalProcess
1622 let mockTerminal : any
23+ type TestVscodeTerminal = vscode . Terminal & {
24+ shellIntegration : {
25+ executeCommand : any
26+ }
27+ }
1728 let mockTerminalInfo : Terminal
1829 let mockExecution : any
1930 let mockStream : AsyncIterableIterator < string >
@@ -33,16 +44,12 @@ describe("TerminalProcess", () => {
3344 hide : vi . fn ( ) ,
3445 show : vi . fn ( ) ,
3546 sendText : vi . fn ( ) ,
36- } as unknown as vscode . Terminal & {
37- shellIntegration : {
38- executeCommand : any
39- }
40- }
47+ } as unknown as TestVscodeTerminal
4148
4249 mockTerminalInfo = new Terminal ( 1 , mockTerminal , "./" )
4350
4451 // Create a process for testing
45- terminalProcess = new TerminalProcess ( mockTerminalInfo )
52+ terminalProcess = new TestTerminalProcess ( mockTerminalInfo )
4653
4754 TerminalRegistry [ "terminals" ] . push ( mockTerminalInfo )
4855
@@ -245,8 +252,7 @@ describe("TerminalProcess", () => {
245252 terminalProcess [ "fullOutput" ] = "test output data"
246253 terminalProcess [ "lastRetrievedIndex" ] = 16 // Same as fullOutput.length
247254
248- // Access the protected method through type casting
249- ; ( terminalProcess as any ) . trimRetrievedOutput ( )
255+ terminalProcess . callTrimRetrievedOutput ( )
250256
251257 expect ( terminalProcess [ "fullOutput" ] ) . toBe ( "" )
252258 expect ( terminalProcess [ "lastRetrievedIndex" ] ) . toBe ( 0 )
@@ -256,7 +262,7 @@ describe("TerminalProcess", () => {
256262 // Set up a scenario where not all output has been retrieved
257263 terminalProcess [ "fullOutput" ] = "test output data"
258264 terminalProcess [ "lastRetrievedIndex" ] = 5 // Less than fullOutput.length
259- ; ( terminalProcess as any ) . trimRetrievedOutput ( )
265+ terminalProcess . callTrimRetrievedOutput ( )
260266
261267 // Buffer should NOT be cleared - there's still unretrieved content
262268 expect ( terminalProcess [ "fullOutput" ] ) . toBe ( "test output data" )
@@ -266,7 +272,7 @@ describe("TerminalProcess", () => {
266272 it ( "does nothing when buffer is already empty" , ( ) => {
267273 terminalProcess [ "fullOutput" ] = ""
268274 terminalProcess [ "lastRetrievedIndex" ] = 0
269- ; ( terminalProcess as any ) . trimRetrievedOutput ( )
275+ terminalProcess . callTrimRetrievedOutput ( )
270276
271277 expect ( terminalProcess [ "fullOutput" ] ) . toBe ( "" )
272278 expect ( terminalProcess [ "lastRetrievedIndex" ] ) . toBe ( 0 )
@@ -276,7 +282,7 @@ describe("TerminalProcess", () => {
276282 // Edge case: index is greater than current length (could happen if output was modified)
277283 terminalProcess [ "fullOutput" ] = "short"
278284 terminalProcess [ "lastRetrievedIndex" ] = 100
279- ; ( terminalProcess as any ) . trimRetrievedOutput ( )
285+ terminalProcess . callTrimRetrievedOutput ( )
280286
281287 expect ( terminalProcess [ "fullOutput" ] ) . toBe ( "" )
282288 expect ( terminalProcess [ "lastRetrievedIndex" ] ) . toBe ( 0 )
0 commit comments