@@ -5,7 +5,7 @@ const core = require('@actions/core')
5
5
const sinon = require ( 'sinon' )
6
6
7
7
describe ( 'release-please-action' , ( ) => {
8
- it ( 'both opens PR and tags GitHub releases by default' , async ( ) => {
8
+ it ( 'both opens PR to the default branch and tags GitHub releases by default' , async ( ) => {
9
9
const output = { }
10
10
core . setOutput = ( name , value ) => {
11
11
output [ name ] = value
@@ -26,17 +26,59 @@ describe('release-please-action', () => {
26
26
return Release
27
27
}
28
28
const releasePR = sinon . stub ( ) . returns ( 25 )
29
+ const buildStatic = sinon . stub ( ) . returns ( {
30
+ run : releasePR
31
+ } )
29
32
action . getReleasePRFactory = ( ) => {
30
33
return {
31
- buildStatic : ( ) => {
32
- return {
33
- run : releasePR
34
- }
35
- }
34
+ buildStatic
35
+ }
36
+ }
37
+ await action . main ( )
38
+ sinon . assert . calledOnce ( createRelease )
39
+ sinon . assert . calledWith ( buildStatic , 'node' , sinon . match . hasOwn ( 'defaultBranch' , undefined ) )
40
+ sinon . assert . calledOnce ( releasePR )
41
+ assert . deepStrictEqual ( output , {
42
+ release_created : true ,
43
+ upload_url : 'http://example.com' ,
44
+ tag_name : 'v1.0.0' ,
45
+ pr : 25
46
+ } )
47
+ } )
48
+
49
+ it ( 'both opens PR to a different default branch and tags GitHub releases by default' , async ( ) => {
50
+ const output = { }
51
+ core . setOutput = ( name , value ) => {
52
+ output [ name ] = value
53
+ }
54
+ const input = {
55
+ 'release-type' : 'node' ,
56
+ 'default-branch' : 'dev'
57
+ }
58
+ core . getInput = ( name ) => {
59
+ return input [ name ]
60
+ }
61
+ const createRelease = sinon . stub ( ) . returns ( {
62
+ upload_url : 'http://example.com' ,
63
+ tag_name : 'v1.0.0'
64
+ } )
65
+ action . getGitHubRelease = ( ) => {
66
+ class Release { }
67
+ Release . prototype . createRelease = createRelease
68
+ return Release
69
+ }
70
+ const releasePR = sinon . stub ( ) . returns ( 25 )
71
+ const buildStatic = sinon . stub ( ) . returns ( {
72
+ run : releasePR
73
+ } )
74
+ action . getReleasePRFactory = ( ) => {
75
+ return {
76
+ buildStatic
36
77
}
37
78
}
38
79
await action . main ( )
39
80
sinon . assert . calledOnce ( createRelease )
81
+ sinon . assert . calledWith ( buildStatic , 'node' , sinon . match . hasOwn ( 'defaultBranch' , 'dev' ) )
40
82
sinon . assert . calledOnce ( releasePR )
41
83
assert . deepStrictEqual ( output , {
42
84
release_created : true ,
0 commit comments