File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed 
server/src/util/__tests__ Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ import  *  as  ChildPorcess  from  'child_process' 
2+ // @ts -ignore 
3+ ChildPorcess . spawn  =  jest . fn ( ChildPorcess . spawn ) 
4+ 
15/* eslint-disable no-useless-escape */ 
26import  *  as  sh  from  '../sh' 
37
8+ describe ( 'execShellScript' ,  ( )  =>  { 
9+  it ( 'resolves if childprocess sends close signal' ,  async  ( )  =>  { 
10+  // @ts -ignore 
11+  ChildPorcess . spawn . mockReturnValueOnce ( { 
12+  stdout : { 
13+  on : ( eventName : string ,  cb : ( s : string )  =>  { } )  =>  { 
14+  setImmediate ( ( )  =>  { 
15+  cb ( 'abc' ) 
16+  } ) 
17+  } , 
18+  } , 
19+  on : ( eventName : string ,  cb : ( n : number )  =>  { } )  =>  { 
20+  setImmediate ( ( )  =>  { 
21+  cb ( 0 ) 
22+  } ) 
23+  } , 
24+  } ) 
25+  return  expect ( sh . execShellScript ( 'something' ) ) . resolves . toBe ( 'abc' ) 
26+  } ) 
27+ 
28+  it ( 'rejects if childprocess sends error signal' ,  async  ( )  =>  { 
29+  // @ts -ignore 
30+  ChildPorcess . spawn . mockReturnValueOnce ( { 
31+  stdout : { 
32+  on : ( eventName : string ,  cb : ( s : string )  =>  { } )  =>  { 
33+  setImmediate ( ( )  =>  { 
34+  cb ( 'abc' ) 
35+  } ) 
36+  } , 
37+  } , 
38+  on : ( eventName : string ,  cb : ( err : Error )  =>  { } )  =>  { 
39+  setImmediate ( ( )  =>  { 
40+  cb ( new  Error ( 'err' ) ) 
41+  } ) 
42+  } , 
43+  } ) 
44+  return  expect ( sh . execShellScript ( 'something' ) ) . rejects . toBe ( 
45+  'Failed to execute something' , 
46+  ) 
47+  } ) 
48+ } ) 
49+ 
450describe ( 'getDocumentation' ,  ( )  =>  { 
551 it ( 'returns null for an unknown builtin' ,  async  ( )  =>  { 
652 const  result  =  await  sh . getShellDocumentation ( {  word : 'foobar'  } ) 
                                 You can’t perform that action at this time. 
               
                  
0 commit comments