@@ -16,43 +16,43 @@ describe('release-please-action', () => {
1616 core . getInput = ( name ) => {
1717 return input [ name ]
1818 }
19- const createRelease = sinon . stub ( ) . returns ( {
19+
20+ let GithubReleaseStub = sinon . stub ( )
21+ const githubReleaseRunStub = sinon . stub ( ) . returns ( {
2022 upload_url : 'http://example.com' ,
2123 tag_name : 'v1.0.0'
2224 } )
23- let ReleaseStub = sinon . stub ( )
2425 action . getGitHubRelease = ( ) => {
25- class Release {
26- createRelease ( ) { }
26+ class GithubRelease {
27+ run ( ) { }
2728 }
28- ReleaseStub = sinon . spy ( function ( ) {
29- const instance = sinon . createStubInstance ( Release )
30- instance . createRelease = createRelease
29+ GithubReleaseStub = sinon . spy ( function ( ) {
30+ const instance = sinon . createStubInstance ( GithubRelease )
31+ instance . run = githubReleaseRunStub
3132 return instance
3233 } )
33- return ReleaseStub
34+ return GithubReleaseStub
3435 }
3536
3637 let GithubReleasePRStub = sinon . stub ( )
37- const runStub = sinon . stub ( ) . returns ( 25 )
38-
38+ const githubReleasePRRunStub = sinon . stub ( ) . returns ( 25 )
3939 action . getReleasePR = ( ) => {
4040 class GithubReleasePR {
4141 run ( ) { }
4242 }
4343 GithubReleasePRStub = sinon . spy ( function ( ) {
4444 const instance = sinon . createStubInstance ( GithubReleasePR )
45- instance . run = runStub
45+ instance . run = githubReleasePRRunStub
4646 return instance
4747 } )
4848 return GithubReleasePRStub
4949 }
5050
5151 await action . main ( )
5252
53- sinon . assert . calledOnce ( createRelease )
54- sinon . assert . calledWith ( ReleaseStub , sinon . match . hasOwn ( 'defaultBranch' , undefined ) )
55- sinon . assert . calledOnce ( runStub )
53+ sinon . assert . calledOnce ( githubReleaseRunStub )
54+ sinon . assert . calledWith ( GithubReleaseStub , sinon . match . hasOwn ( 'defaultBranch' , undefined ) )
55+ sinon . assert . calledOnce ( githubReleasePRRunStub )
5656 sinon . assert . calledWith ( GithubReleasePRStub , sinon . match . hasOwn ( 'defaultBranch' , undefined ) )
5757 assert . deepStrictEqual ( output , {
5858 release_created : true ,
@@ -74,45 +74,45 @@ describe('release-please-action', () => {
7474 core . getInput = ( name ) => {
7575 return input [ name ]
7676 }
77- const createRelease = sinon . stub ( ) . returns ( {
77+
78+ let GithubReleaseStub = sinon . stub ( )
79+ const githubReleaseRunStub = sinon . stub ( ) . returns ( {
7880 upload_url : 'http://example.com' ,
7981 tag_name : 'v1.0.0'
8082 } )
81-
82- let ReleaseStub = sinon . stub ( )
8383 action . getGitHubRelease = ( ) => {
84- class Release {
85- createRelease ( ) { }
84+ class GithubRelease {
85+ run ( ) { }
8686 }
87- ReleaseStub = sinon . spy ( function ( ) {
88- const instance = sinon . createStubInstance ( Release )
89- instance . createRelease = createRelease
87+ GithubReleaseStub = sinon . spy ( function ( ) {
88+ const instance = sinon . createStubInstance ( GithubRelease )
89+ instance . run = githubReleaseRunStub
9090 return instance
9191 } )
92- return ReleaseStub
92+ return GithubReleaseStub
9393 }
9494
9595 let GithubReleasePRStub = sinon . stub ( )
96- const runStub = sinon . stub ( ) . returns ( 25 )
97-
96+ const githubReleasePRRunStub = sinon . stub ( ) . returns ( 25 )
9897 action . getReleasePR = ( ) => {
9998 class GithubReleasePR {
10099 run ( ) { }
101100 }
102101 GithubReleasePRStub = sinon . spy ( function ( ) {
103102 const instance = sinon . createStubInstance ( GithubReleasePR )
104- instance . run = runStub
103+ instance . run = githubReleasePRRunStub
105104 return instance
106105 } )
107106 return GithubReleasePRStub
108107 }
109108
110109 await action . main ( )
111110
112- sinon . assert . calledOnce ( createRelease )
113- sinon . assert . calledWith ( ReleaseStub , sinon . match . hasOwn ( 'defaultBranch' , 'dev' ) )
114- sinon . assert . calledOnce ( runStub )
111+ sinon . assert . calledOnce ( githubReleaseRunStub )
112+ sinon . assert . calledWith ( GithubReleaseStub , sinon . match . hasOwn ( 'defaultBranch' , 'dev' ) )
113+ sinon . assert . calledOnce ( githubReleasePRRunStub )
115114 sinon . assert . calledWith ( GithubReleasePRStub , sinon . match . hasOwn ( 'defaultBranch' , 'dev' ) )
115+
116116 assert . deepStrictEqual ( output , {
117117 release_created : true ,
118118 upload_url : 'http://example.com' ,
@@ -133,34 +133,41 @@ describe('release-please-action', () => {
133133 core . getInput = ( name ) => {
134134 return input [ name ]
135135 }
136- const githubRelease = sinon . stub ( ) . returns ( {
136+
137+ let GithubReleaseStub = sinon . stub ( )
138+ const githubReleaseRunStub = sinon . stub ( ) . returns ( {
137139 upload_url : 'http://example.com' ,
138140 tag_name : 'v1.0.0'
139141 } )
140142 action . getGitHubRelease = ( ) => {
141- class Release { }
142- Release . prototype . createRelease = githubRelease
143- return Release
143+ class GithubRelease {
144+ run ( ) { }
145+ }
146+ GithubReleaseStub = sinon . spy ( function ( ) {
147+ const instance = sinon . createStubInstance ( GithubRelease )
148+ instance . run = githubReleaseRunStub
149+ return instance
150+ } )
151+ return GithubReleaseStub
144152 }
145153
146154 let GithubReleasePRStub = sinon . stub ( )
147- const runStub = sinon . stub ( ) . returns ( 25 )
148-
155+ const githubReleasePRRunStub = sinon . stub ( ) . returns ( 25 )
149156 action . getReleasePR = ( ) => {
150157 class GithubReleasePR {
151158 run ( ) { }
152159 }
153160 GithubReleasePRStub = sinon . spy ( function ( ) {
154161 const instance = sinon . createStubInstance ( GithubReleasePR )
155- instance . run = runStub
162+ instance . run = githubReleasePRRunStub
156163 return instance
157164 } )
158165 return GithubReleasePRStub
159166 }
160167
161168 await action . main ( )
162- sinon . assert . notCalled ( githubRelease )
163- sinon . assert . calledOnce ( runStub )
169+ sinon . assert . notCalled ( githubReleaseRunStub )
170+ sinon . assert . calledOnce ( githubReleasePRRunStub )
164171 } )
165172
166173 it ( 'only creates GitHub release, if command set to github-release' , async ( ) => {
@@ -175,28 +182,41 @@ describe('release-please-action', () => {
175182 core . getInput = ( name ) => {
176183 return input [ name ]
177184 }
178- const githubRelease = sinon . stub ( ) . returns ( {
185+
186+ let GithubReleaseStub = sinon . stub ( )
187+ const githubReleaseRunStub = sinon . stub ( ) . returns ( {
179188 upload_url : 'http://example.com' ,
180189 tag_name : 'v1.0.0'
181190 } )
182191 action . getGitHubRelease = ( ) => {
183- class Release { }
184- Release . prototype . createRelease = githubRelease
185- return Release
186- }
187- const releasePR = sinon . stub ( )
188- action . getReleasePRFactory = ( ) => {
189- return {
190- buildStatic : ( ) => {
191- return {
192- run : releasePR
193- }
194- }
192+ class GithubRelease {
193+ run ( ) { }
195194 }
195+ GithubReleaseStub = sinon . spy ( function ( ) {
196+ const instance = sinon . createStubInstance ( GithubRelease )
197+ instance . run = githubReleaseRunStub
198+ return instance
199+ } )
200+ return GithubReleaseStub
201+ }
202+
203+ let GithubReleasePRStub = sinon . stub ( )
204+ const githubReleasePRRunStub = sinon . stub ( ) . returns ( 25 )
205+ action . getReleasePR = ( ) => {
206+ class GithubReleasePR {
207+ run ( ) { }
208+ }
209+ GithubReleasePRStub = sinon . spy ( function ( ) {
210+ const instance = sinon . createStubInstance ( GithubReleasePR )
211+ instance . run = githubReleasePRRunStub
212+ return instance
213+ } )
214+ return GithubReleasePRStub
196215 }
216+
197217 await action . main ( )
198- sinon . assert . calledOnce ( githubRelease )
199- sinon . assert . notCalled ( releasePR )
218+ sinon . assert . calledOnce ( githubReleaseRunStub )
219+ sinon . assert . notCalled ( githubReleasePRRunStub )
200220 } )
201221
202222 it ( 'sets approprite outputs when GitHub release created' , async ( ) => {
@@ -223,22 +243,35 @@ describe('release-please-action', () => {
223243 core . getInput = ( name ) => {
224244 return input [ name ]
225245 }
226- const githubRelease = sinon . stub ( ) . returns ( expected )
246+
247+ let GithubReleaseStub = sinon . stub ( )
248+ const githubReleaseRunStub = sinon . stub ( ) . returns ( expected )
227249 action . getGitHubRelease = ( ) => {
228- class Release { }
229- Release . prototype . createRelease = githubRelease
230- return Release
231- }
232- const releasePR = sinon . stub ( )
233- action . getReleasePRFactory = ( ) => {
234- return {
235- buildStatic : ( ) => {
236- return {
237- run : releasePR
238- }
239- }
250+ class GithubRelease {
251+ run ( ) { }
240252 }
253+ GithubReleaseStub = sinon . spy ( function ( ) {
254+ const instance = sinon . createStubInstance ( GithubRelease )
255+ instance . run = githubReleaseRunStub
256+ return instance
257+ } )
258+ return GithubReleaseStub
241259 }
260+
261+ let GithubReleasePRStub = sinon . stub ( )
262+ const githubReleasePRRunStub = sinon . stub ( ) . returns ( 25 )
263+ action . getReleasePR = ( ) => {
264+ class GithubReleasePR {
265+ run ( ) { }
266+ }
267+ GithubReleasePRStub = sinon . spy ( function ( ) {
268+ const instance = sinon . createStubInstance ( GithubReleasePR )
269+ instance . run = githubReleasePRRunStub
270+ return instance
271+ } )
272+ return GithubReleasePRStub
273+ }
274+
242275 await action . main ( )
243276 assert . deepStrictEqual ( output , expected )
244277 } )
@@ -255,20 +288,21 @@ describe('release-please-action', () => {
255288 core . getInput = ( name ) => {
256289 return input [ name ]
257290 }
258- let GithubReleasePRStub = sinon . stub ( )
259- const runStub = sinon . stub ( ) . returns ( 95 )
260291
292+ let GithubReleasePRStub = sinon . stub ( )
293+ const githubReleasePRRunStub = sinon . stub ( ) . returns ( 95 )
261294 action . getReleasePR = ( ) => {
262295 class GithubReleasePR {
263296 run ( ) { }
264297 }
265298 GithubReleasePRStub = sinon . spy ( function ( ) {
266299 const instance = sinon . createStubInstance ( GithubReleasePR )
267- instance . run = runStub
300+ instance . run = githubReleasePRRunStub
268301 return instance
269302 } )
270303 return GithubReleasePRStub
271304 }
305+
272306 await action . main ( )
273307 assert . strictEqual ( output . pr , 95 )
274308 } )
@@ -285,20 +319,21 @@ describe('release-please-action', () => {
285319 core . getInput = ( name ) => {
286320 return input [ name ]
287321 }
288- let GithubReleasePRStub = sinon . stub ( )
289- const runStub = sinon . stub ( ) . returns ( undefined )
290322
323+ let GithubReleasePRStub = sinon . stub ( )
324+ const githubReleasePRRunStub = sinon . stub ( ) . returns ( undefined )
291325 action . getReleasePR = ( ) => {
292326 class GithubReleasePR {
293327 run ( ) { }
294328 }
295329 GithubReleasePRStub = sinon . spy ( function ( ) {
296330 const instance = sinon . createStubInstance ( GithubReleasePR )
297- instance . run = runStub
331+ instance . run = githubReleasePRRunStub
298332 return instance
299333 } )
300334 return GithubReleasePRStub
301335 }
336+
302337 await action . main ( )
303338 assert . strictEqual ( Object . hasOwnProperty . call ( output , 'pr' ) , false )
304339 } )
0 commit comments