@@ -8,39 +8,37 @@ function getCompletion(args) {
8
8
return new Promise ( resolve => completions . getCompletion ( args , resolve ) ) ;
9
9
}
10
10
11
- jest . mock ( './tree' , ( ) => {
12
- return {
13
- codefresh : {
14
- get : {
15
- pipelines : {
16
- __positionalHandler : './pipelines/get.completion' ,
17
- } ,
18
- pip : {
19
- alias : 'pipelines' ,
20
- } ,
21
- __optionHandlers : [ './pipelines/get.completion' ] ,
11
+ jest . mock ( './tree' , ( ) => ( {
12
+ codefresh : {
13
+ get : {
14
+ pipelines : {
15
+ __positionalHandler : './pipelines/get.completion' ,
22
16
} ,
23
- generate : { } ,
24
- create : {
25
- context : {
26
- git : { } ,
27
- config : { } ,
28
- __optionHandlers : [ './context/create.completion' , './root/create.completion' ] ,
29
- } ,
30
- repository : { } ,
31
- __optionHandlers : [ './root/create.completion' , './root/another.completion' ] ,
17
+ pip : {
18
+ alias : 'pipelines' ,
32
19
} ,
33
- crt : {
34
- alias : 'create' ,
35
- context : {
36
- git_of_alias : { } , // typically should be equal to create.context, just for test
37
- config : { } ,
38
- } ,
39
- repository : { } ,
20
+ __optionHandlers : [ './pipelines/get.completion' ] ,
21
+ } ,
22
+ generate : { } ,
23
+ create : {
24
+ context : {
25
+ git : { } ,
26
+ config : { } ,
27
+ __optionHandlers : [ './context/create.completion' , './root/create.completion' ] ,
40
28
} ,
29
+ repository : { } ,
30
+ __optionHandlers : [ './root/create.completion' , './root/another.completion' ] ,
41
31
} ,
42
- } ;
43
- } , { virtual : true } ) ;
32
+ crt : {
33
+ alias : 'create' ,
34
+ context : {
35
+ git_of_alias : { } , // typically should be equal to create.context, just for test
36
+ config : { } ,
37
+ } ,
38
+ repository : { } ,
39
+ } ,
40
+ } ,
41
+ } ) , { virtual : true } ) ;
44
42
45
43
jest . mock ( './pipelines/get.completion' , ( ) => { // eslint-disable-line
46
44
return {
@@ -111,6 +109,12 @@ jest.mock('fs', () => {
111
109
isDirectory : ( ) => isDir ,
112
110
} ;
113
111
} ;
112
+
113
+ const stat = ( p , options = { bigint : false } , callback ) => {
114
+ const result = lstatSync ( p ) ;
115
+ return callback ( null , result ) ;
116
+ } ;
117
+
114
118
const readdirSync = ( p ) => {
115
119
if ( p . startsWith ( `${ process . cwd ( ) } /` ) ) {
116
120
p = p . replace ( `${ process . cwd ( ) } /` , '' ) ;
@@ -129,6 +133,9 @@ jest.mock('fs', () => {
129
133
}
130
134
} ;
131
135
return {
136
+ lstat : ( p , options , callback ) => callback ( null , lstatSync ( p ) ) ,
137
+ stat : ( p , options , callback ) => callback ( null , lstatSync ( p ) ) ,
138
+ access : ( path , c ) => c ( null , true ) ,
132
139
readdirSync,
133
140
existsSync,
134
141
lstatSync,
@@ -236,7 +243,6 @@ describe('codefresh completions', () => {
236
243
} ) ;
237
244
238
245
describe ( 'filedir' , ( ) => {
239
-
240
246
it ( 'should return "__files_completion__" literal to shell without --impl-file-dir' , async ( ) => {
241
247
process . argv = [ 'codefresh' , 'get' , '-f' , '' ] ;
242
248
const result = await getCompletion ( process . argv ) ;
0 commit comments