@@ -455,7 +455,7 @@ suite('Set Interpreter Command', () => {
455
455
verify ( interpreterService . triggerRefresh ( ) ) . once ( ) ;
456
456
} ) ;
457
457
458
- test ( 'If an event to update quickpick is received, the quickpick is updated accordingly' , async ( ) => {
458
+ test ( 'Events to update quickpick updates the quickpick accordingly' , async ( ) => {
459
459
const state : InterpreterStateArgs = { path : 'some path' , workspace : undefined } ;
460
460
const multiStepInput = TypeMoq . Mock . ofType < IMultiStepInput < InterpreterStateArgs > > ( ) ;
461
461
let actualParameters : IQuickPickParameters < QuickPickItem > | undefined ;
@@ -516,7 +516,9 @@ suite('Set Interpreter Command', () => {
516
516
. setup ( ( i ) => i . getRecommendedSuggestion ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
517
517
. returns ( ( ) => refreshedItem ) ;
518
518
interpreterSelector
519
- . setup ( ( i ) => i . suggestionToQuickPickItem ( TypeMoq . It . isAny ( ) , undefined , false ) )
519
+ . setup ( ( i ) =>
520
+ i . suggestionToQuickPickItem ( TypeMoq . It . isValue ( refreshedItem . interpreter ) , undefined , false ) ,
521
+ )
520
522
. returns ( ( ) => refreshedItem ) ;
521
523
when ( interpreterService . refreshPromise ) . thenReturn ( undefined ) ;
522
524
@@ -542,6 +544,54 @@ suite('Set Interpreter Command', () => {
542
544
} ,
543
545
'Quickpick not updated correctly after refresh has finished' ,
544
546
) ;
547
+
548
+ const newItem = {
549
+ description : `${ workspacePath } /interpreterPath1` ,
550
+ detail : '' ,
551
+ label : 'This is the selected Python path' ,
552
+ path : `${ workspacePath } /interpreterPath1` ,
553
+ interpreter : {
554
+ path : `${ workspacePath } /interpreterPath1` ,
555
+ envType : EnvironmentType . Venv ,
556
+ } as PythonEnvironment ,
557
+ } ;
558
+ const changeEvent2 : PythonEnvironmentsChangedEvent = {
559
+ old : undefined ,
560
+ new : newItem . interpreter ,
561
+ } ;
562
+ interpreterSelector . reset ( ) ;
563
+ interpreterSelector
564
+ . setup ( ( i ) => i . getSuggestions ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
565
+ . returns ( ( ) => [ refreshedItem , newItem ] ) ;
566
+ interpreterSelector
567
+ . setup ( ( i ) => i . getRecommendedSuggestion ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
568
+ . returns ( ( ) => refreshedItem ) ;
569
+ interpreterSelector
570
+ . setup ( ( i ) =>
571
+ i . suggestionToQuickPickItem ( TypeMoq . It . isValue ( refreshedItem . interpreter ) , undefined , false ) ,
572
+ )
573
+ . returns ( ( ) => refreshedItem ) ;
574
+ interpreterSelector
575
+ . setup ( ( i ) => i . suggestionToQuickPickItem ( TypeMoq . It . isValue ( newItem . interpreter ) , undefined , false ) )
576
+ . returns ( ( ) => newItem ) ;
577
+ await onChangedCallback ! ( changeEvent2 , ( quickPick as unknown ) as QuickPick < QuickPickItem > ) ; // Invoke callback, meaning that the items are supposed to change.
578
+
579
+ assert . deepStrictEqual (
580
+ quickPick ,
581
+ {
582
+ items : [
583
+ expectedEnterInterpreterPathSuggestion ,
584
+ defaultInterpreterPathSuggestion ,
585
+ separator ,
586
+ recommended ,
587
+ { label : EnvGroups . Workspace , kind : QuickPickItemKind . Separator } ,
588
+ newItem ,
589
+ ] ,
590
+ activeItems : [ recommended ] ,
591
+ busy : false ,
592
+ } ,
593
+ 'Quickpick not updated correctly' ,
594
+ ) ;
545
595
} ) ;
546
596
547
597
test ( 'If an item is selected, update state and return' , async ( ) => {
0 commit comments