1- jest . mock ( "./pipelines" ) ; 
2- 
31import  {  disableVerboseLogging ,  enableVerboseLogging  }  from  "../../logger" ; 
42
53import  { 
6-   IAzureRepoPipelineConfig , 
4+   createPipelineForDefinition , 
5+   definitionForAzureRepoPipeline , 
6+   definitionForGithubRepoPipeline , 
7+   getBuildApiClient , 
78  GithubRepoPipelineConfig , 
9+   IAzureRepoPipelineConfig , 
10+   queueBuild , 
811  RepositoryTypes 
912}  from  "./pipelines" ; 
10- 
1113import  { 
1214  BuildDefinition , 
1315  BuildRepository , 
1416  YamlProcess 
1517}  from  "azure-devops-node-api/interfaces/BuildInterfaces" ; 
18+ import  *  as  azdoClient  from  "../azdoClient" ; 
1619
1720beforeAll ( ( )  =>  { 
1821  enableVerboseLogging ( ) ; 
@@ -22,9 +25,15 @@ afterAll(() => {
2225  disableVerboseLogging ( ) ; 
2326} ) ; 
2427
25- describe ( "It builds an azure repo pipeline definition" ,  ( )  =>  { 
26-   const  {  definitionForAzureRepoPipeline }  =  jest . requireActual ( "./pipelines" ) ; 
28+ describe ( "test getBuildApiClient function" ,  ( )  =>  { 
29+   it ( "positive test" ,  async  ( )  =>  { 
30+     // eslint-disable-next-line @typescript-eslint/no-explicit-any 
31+     jest . spyOn ( azdoClient ,  "getBuildApi" ) . mockResolvedValueOnce ( { }  as  any ) ; 
32+     await  expect ( getBuildApiClient ( "org" ,  "token" ) ) . toBeDefined ( ) ; 
33+   } ) ; 
34+ } ) ; 
2735
36+ describe ( "It builds an azure repo pipeline definition" ,  ( )  =>  { 
2837  test ( "pipeline definition is well-formed" ,  ( )  =>  { 
2938    const  sampleAzureConfig  =  { 
3039      branchFilters : [ "master" ] , 
@@ -70,8 +79,6 @@ describe("It builds an azure repo pipeline definition", () => {
7079} ) ; 
7180
7281describe ( "It builds a github repo pipeline definition" ,  ( )  =>  { 
73-   const  {  definitionForGithubRepoPipeline }  =  jest . requireActual ( "./pipelines" ) ; 
74- 
7582  test ( "pipeline definition is well-formed" ,  ( )  =>  { 
7683    const  sampleGithubConfig  =  { 
7784      branchFilters : [ "master" ] , 
@@ -122,3 +129,67 @@ describe("It builds a github repo pipeline definition", () => {
122129    } 
123130  } ) ; 
124131} ) ; 
132+ 
133+ describe ( "test createPipelineForDefinition function" ,  ( )  =>  { 
134+   it ( "positive test" ,  async  ( )  =>  { 
135+     const  result  =  await  createPipelineForDefinition ( 
136+       { 
137+         createDefinition : ( )  =>  { 
138+           return  { } ; 
139+         } 
140+         // eslint-disable-next-line @typescript-eslint/no-explicit-any 
141+       }  as  any , 
142+       "project" , 
143+       // eslint-disable-next-line @typescript-eslint/no-explicit-any 
144+       { }  as  any 
145+     ) ; 
146+     expect ( result ) . toBeDefined ( ) ; 
147+   } ) ; 
148+   it ( "negative test" ,  async  ( )  =>  { 
149+     await  expect ( 
150+       createPipelineForDefinition ( 
151+         { 
152+           createDefinition : ( )  =>  { 
153+             throw  Error ( "fake" ) ; 
154+           } 
155+           // eslint-disable-next-line @typescript-eslint/no-explicit-any 
156+         }  as  any , 
157+         "project" , 
158+         // eslint-disable-next-line @typescript-eslint/no-explicit-any 
159+         { }  as  any 
160+       ) 
161+     ) . rejects . toThrow ( ) ; 
162+   } ) ; 
163+ } ) ; 
164+ 
165+ describe ( "test queueBuild function" ,  ( )  =>  { 
166+   it ( "positive test" ,  async  ( )  =>  { 
167+     const  result  =  await  queueBuild ( 
168+       { 
169+         queueBuild : ( )  =>  { 
170+           return  { } ; 
171+         } 
172+         // eslint-disable-next-line @typescript-eslint/no-explicit-any 
173+       }  as  any , 
174+       "project" , 
175+       // eslint-disable-next-line @typescript-eslint/no-explicit-any 
176+       { }  as  any 
177+     ) ; 
178+     expect ( result ) . toBeDefined ( ) ; 
179+   } ) ; 
180+   it ( "negative test" ,  async  ( )  =>  { 
181+     await  expect ( 
182+       queueBuild ( 
183+         { 
184+           queueBuild : ( )  =>  { 
185+             throw  Error ( "fake" ) ; 
186+           } 
187+           // eslint-disable-next-line @typescript-eslint/no-explicit-any 
188+         }  as  any , 
189+         "project" , 
190+         // eslint-disable-next-line @typescript-eslint/no-explicit-any 
191+         { }  as  any 
192+       ) 
193+     ) . rejects . toThrow ( ) ; 
194+   } ) ; 
195+ } ) ; 
0 commit comments