@@ -154,6 +154,32 @@ suite('Shell Detector', () => {
154154
155155 const  shell  =  shellDetector . identifyTerminalShell ( ) ; 
156156
157+  expect ( shell ) . to . be . equal ( detectedShell ) ; 
158+  verify ( detector1 . identify ( anything ( ) ,  anything ( ) ) ) . never ( ) ; 
159+  verify ( detector2 . identify ( anything ( ) ,  undefined ) ) . once ( ) ; 
160+  verify ( detector3 . identify ( anything ( ) ,  anything ( ) ) ) . once ( ) ; 
161+  verify ( detector4 . identify ( anything ( ) ,  anything ( ) ) ) . once ( ) ; 
162+  } ) ; 
163+  test ( `Fall back to detectors that can identify a shell ${ testSuffix }   (even if detected shell is other)` ,  ( )  =>  { 
164+  when ( platformService . osType ) . thenReturn ( os . value ) ; 
165+  const  detector1  =  mock ( UserEnvironmentShellDetector ) ; 
166+  const  detector2  =  mock ( UserEnvironmentShellDetector ) ; 
167+  const  detector3  =  mock ( UserEnvironmentShellDetector ) ; 
168+  const  detector4  =  mock ( UserEnvironmentShellDetector ) ; 
169+  const  detectedShell  =  TerminalShellType . xonsh ; 
170+  when ( detector1 . priority ) . thenReturn ( 1 ) ; 
171+  when ( detector2 . priority ) . thenReturn ( 2 ) ; 
172+  when ( detector3 . priority ) . thenReturn ( 3 ) ; 
173+  when ( detector4 . priority ) . thenReturn ( 4 ) ; 
174+  when ( detector1 . identify ( anything ( ) ,  anything ( ) ) ) . thenReturn ( TerminalShellType . ksh ) ; 
175+  when ( detector2 . identify ( anything ( ) ,  anything ( ) ) ) . thenReturn ( detectedShell ) ; 
176+  when ( detector3 . identify ( anything ( ) ,  anything ( ) ) ) . thenReturn ( TerminalShellType . other ) ; 
177+  when ( detector4 . identify ( anything ( ) ,  anything ( ) ) ) . thenReturn ( TerminalShellType . other ) ; 
178+  const  shellDetector  =  new  ShellDetector ( instance ( platformService ) ,  [ instance ( detector1 ) ,  instance ( detector2 ) , 
179+  instance ( detector3 ) ,  instance ( detector4 ) ] ) ; 
180+ 
181+  const  shell  =  shellDetector . identifyTerminalShell ( ) ; 
182+ 
157183 expect ( shell ) . to . be . equal ( detectedShell ) ; 
158184 verify ( detector1 . identify ( anything ( ) ,  anything ( ) ) ) . never ( ) ; 
159185 verify ( detector2 . identify ( anything ( ) ,  undefined ) ) . once ( ) ; 
0 commit comments