@@ -240,6 +240,37 @@ describe('LiveWatchTreeDataProvider', () => {
240240 expect ( vscode . env . clipboard . writeText ) . toHaveBeenCalledWith ( 'myExpression' ) ;
241241 } ) ;
242242
243+ it ( 'set root value and send a setExpression request to session and calls refresh right after' , async ( ) => {
244+ const node = makeNode ( 'myVar' , { result : '1' , variablesReference : 0 } , 1 ) ;
245+ const refreshSpy = jest . spyOn ( liveWatchTreeDataProvider as any , 'refresh' ) . mockResolvedValue ( '' ) ;
246+ ( liveWatchTreeDataProvider as any ) . _activeSession = {
247+ session : {
248+ customRequest : jest . fn ( ) . mockResolvedValue ( { result : '2' , variablesReference : 0 } )
249+ } ,
250+ evaluateGlobalExpression : jest . fn ( )
251+ } ;
252+ ( vscode . window as any ) . showInputBox = jest . fn ( ) . mockResolvedValue ( '2' ) ;
253+ await ( liveWatchTreeDataProvider as any ) . handleSetValueCommand ( node ) ;
254+ expect ( ( liveWatchTreeDataProvider as any ) . _activeSession . session . customRequest ) . toHaveBeenCalledWith ( 'setExpression' , { expression : 'myVar' , frameId : 0 , value : '2' } ) ;
255+ expect ( refreshSpy ) . toHaveBeenCalled ( ) ;
256+ } ) ;
257+
258+ it ( 'set child node value and send a setVariable request to session' , async ( ) => {
259+ const parent = makeNode ( 'parentVar' , { result : '1' , variablesReference : 123 } , 1 ) ;
260+ const child = makeNode ( 'childVar' , { result : '1' , variablesReference : 0 } , 2 , parent ) ;
261+ const refreshSpy = jest . spyOn ( liveWatchTreeDataProvider as any , 'refresh' ) . mockResolvedValue ( '' ) ;
262+ ( liveWatchTreeDataProvider as any ) . _activeSession = {
263+ session : {
264+ customRequest : jest . fn ( ) . mockResolvedValue ( { result : '2' , variablesReference : 0 } )
265+ } ,
266+ evaluateGlobalExpression : jest . fn ( )
267+ } ;
268+ ( vscode . window as any ) . showInputBox = jest . fn ( ) . mockResolvedValue ( '2' ) ;
269+ await ( liveWatchTreeDataProvider as any ) . handleSetValueCommand ( child ) ;
270+ expect ( ( liveWatchTreeDataProvider as any ) . _activeSession . session . customRequest ) . toHaveBeenCalledWith ( 'setVariable' , { name : 'childVar' , value : '2' , variablesReference : 123 } ) ;
271+ expect ( refreshSpy ) . toHaveBeenCalled ( ) ;
272+ } ) ;
273+
243274 it ( 'AddFromSelection adds selected text as new live watch expression to roots' , async ( ) => {
244275 jest . spyOn ( liveWatchTreeDataProvider as any , 'evaluate' ) . mockResolvedValue ( { result : '5678' , variablesReference : 0 } ) ;
245276 // Mock the active text editor with fake range
@@ -333,18 +364,19 @@ describe('LiveWatchTreeDataProvider', () => {
333364 it ( 'registers all live watch commands on activate' , async ( ) => {
334365 await liveWatchTreeDataProvider . activate ( tracker ) ;
335366 const calls = ( vscode . commands . registerCommand as jest . Mock ) . mock . calls . map ( call => call [ 0 ] ) ;
336- expect ( calls ) . toEqual ( expect . arrayContaining ( [
367+ expect ( calls ) . toEqual ( [
337368 'vscode-cmsis-debugger.liveWatch.add' ,
338369 'vscode-cmsis-debugger.liveWatch.deleteAll' ,
339370 'vscode-cmsis-debugger.liveWatch.delete' ,
340371 'vscode-cmsis-debugger.liveWatch.refresh' ,
341372 'vscode-cmsis-debugger.liveWatch.modify' ,
342373 'vscode-cmsis-debugger.liveWatch.copy' ,
374+ 'vscode-cmsis-debugger.liveWatch.setValue' ,
343375 'vscode-cmsis-debugger.liveWatch.addToLiveWatchFromTextEditor' ,
344376 'vscode-cmsis-debugger.liveWatch.addToLiveWatchFromWatchWindow' ,
345377 'vscode-cmsis-debugger.liveWatch.addToLiveWatchFromVariablesView' ,
346378 'vscode-cmsis-debugger.liveWatch.showInMemoryInspector'
347- ] ) ) ;
379+ ] ) ;
348380 } ) ;
349381
350382 it ( 'add command adds a node when expression provided' , async ( ) => {
0 commit comments