@@ -210,6 +210,22 @@ describe('LiveWatchTreeDataProvider', () => {
210210 await ( liveWatchTreeDataProvider as any ) . refresh ( node ) ;
211211 expect ( node . value . result ) . toBe ( 'new-value' ) ;
212212 } ) ;
213+
214+ it ( 'refresh without argument evaluates each root and fires tree change once' , async ( ) => {
215+ const nodeA = makeNode ( 'node-A' , { result : 'value-A' , variablesReference : 0 } , 1 ) ;
216+ const nodeB = makeNode ( 'node-B' , { result : 'value-B' , variablesReference : 0 } , 2 ) ;
217+ ( liveWatchTreeDataProvider as any ) . roots = [ nodeA , nodeB ] ;
218+ const evalMock = jest . spyOn ( liveWatchTreeDataProvider as any , 'evaluate' )
219+ . mockImplementation ( async ( expr : unknown ) => ( { result : String ( expr ) + '-updated' , variablesReference : 0 } ) ) ;
220+ const fireSpy = jest . spyOn ( ( liveWatchTreeDataProvider as any ) . _onDidChangeTreeData , 'fire' ) ;
221+ await ( liveWatchTreeDataProvider as any ) . refresh ( ) ;
222+ expect ( evalMock ) . toHaveBeenCalledTimes ( 2 ) ;
223+ expect ( nodeA . value . result ) . toBe ( 'node-A-updated' ) ;
224+ expect ( nodeB . value . result ) . toBe ( 'node-B-updated' ) ;
225+ expect ( fireSpy ) . toHaveBeenCalledTimes ( 1 ) ;
226+ // fire called with undefined (no specific node) per implementation
227+ expect ( fireSpy . mock . calls [ 0 ] [ 0 ] ) . toBeUndefined ( ) ;
228+ } ) ;
213229 } ) ;
214230
215231 describe ( 'command registration' , ( ) => {
@@ -309,5 +325,35 @@ describe('LiveWatchTreeDataProvider', () => {
309325 expect ( refreshSpy ) . toHaveBeenCalled ( ) ;
310326 } ) ;
311327 } ) ;
328+
329+ describe ( 'evaluate' , ( ) => {
330+ it ( 'returns No active session when none set' , async ( ) => {
331+ const result = await ( liveWatchTreeDataProvider as any ) . evaluate ( 'myExpression' ) ;
332+ expect ( result . result ) . toBe ( 'No active session' ) ;
333+ expect ( result . variablesReference ) . toBe ( 0 ) ;
334+ } ) ;
335+
336+ it ( 'maps string result into LiveWatchValue' , async ( ) => {
337+ // mock active session with evaluateGlobalExpression returning a string
338+ ( liveWatchTreeDataProvider as any ) . _activeSession = {
339+ evaluateGlobalExpression : jest . fn ( ) . mockResolvedValue ( 'string-value' ) ,
340+ session : { }
341+ } ;
342+ const evalResult = await ( liveWatchTreeDataProvider as any ) . evaluate ( 'myExpression' ) ;
343+ expect ( evalResult . result ) . toBe ( 'string-value' ) ;
344+ expect ( evalResult . variablesReference ) . toBe ( 0 ) ;
345+ } ) ;
346+
347+ it ( 'maps object result into LiveWatchValue' , async ( ) => {
348+ const responseObj = { result : 'value' , variablesReference : 1234 } ;
349+ ( liveWatchTreeDataProvider as any ) . _activeSession = {
350+ evaluateGlobalExpression : jest . fn ( ) . mockResolvedValue ( responseObj ) ,
351+ session : { }
352+ } ;
353+ const evalResult = await ( liveWatchTreeDataProvider as any ) . evaluate ( 'myExpression' ) ;
354+ expect ( evalResult . result ) . toBe ( 'value' ) ;
355+ expect ( evalResult . variablesReference ) . toBe ( 1234 ) ;
356+ } ) ;
357+ } ) ;
312358} ) ;
313359/* eslint-enable @typescript-eslint/no-explicit-any */
0 commit comments