@@ -10,12 +10,15 @@ describe('Create a branch based on the input', () => {
10
10
let contextMock = JSON . parse ( readFileSync ( '__tests__/context.json' , 'utf8' ) ) ;
11
11
let githubMock = jest . fn ( ) ;
12
12
let octokitMock = {
13
- git : {
14
- createRef : jest . fn ( )
15
- } ,
16
- repos : {
17
- getBranch : jest . fn ( )
13
+ rest : {
14
+ git : {
15
+ createRef : jest . fn ( )
16
+ } ,
17
+ repos : {
18
+ getBranch : jest . fn ( )
19
+ }
18
20
}
21
+
19
22
} ;
20
23
21
24
beforeEach ( ( ) => {
@@ -24,38 +27,38 @@ describe('Create a branch based on the input', () => {
24
27
} ) ;
25
28
26
29
it ( 'gets a branch' , async ( ) => {
27
- octokitMock . repos . getBranch . mockRejectedValue ( new HttpError ( ) )
30
+ octokitMock . rest . repos . getBranch . mockRejectedValue ( new HttpError ( ) )
28
31
process . env . GITHUB_REPOSITORY = 'peterjgrainger/test-action-changelog-reminder'
29
32
await createBranch ( githubMock , context , branch )
30
- expect ( octokitMock . repos . getBranch ) . toHaveBeenCalledWith ( {
33
+ expect ( octokitMock . rest . repos . getBranch ) . toHaveBeenCalledWith ( {
31
34
repo : 'test-action-changelog-reminder' ,
32
35
owner : 'peterjgrainger' ,
33
36
branch
34
37
} )
35
38
} ) ;
36
39
37
40
it ( 'Creates a new branch if not already there' , async ( ) => {
38
- octokitMock . repos . getBranch . mockRejectedValue ( new HttpError ( ) )
41
+ octokitMock . rest . repos . getBranch . mockRejectedValue ( new HttpError ( ) )
39
42
await createBranch ( githubMock , contextMock , branch )
40
- expect ( octokitMock . git . createRef ) . toHaveBeenCalledWith ( {
43
+ expect ( octokitMock . rest . git . createRef ) . toHaveBeenCalledWith ( {
41
44
ref : 'refs/heads/release-v1' ,
42
45
sha : 'ebb4992dc72451c1c6c99e1cce9d741ec0b5b7d7'
43
46
} )
44
47
} ) ;
45
48
46
49
it ( 'Creates a new branch from a given commit SHA' , async ( ) => {
47
- octokitMock . repos . getBranch . mockRejectedValue ( new HttpError ( ) )
50
+ octokitMock . rest . repos . getBranch . mockRejectedValue ( new HttpError ( ) )
48
51
await createBranch ( githubMock , contextMock , branch , sha )
49
- expect ( octokitMock . git . createRef ) . toHaveBeenCalledWith ( {
52
+ expect ( octokitMock . rest . git . createRef ) . toHaveBeenCalledWith ( {
50
53
ref : 'refs/heads/release-v1' ,
51
54
sha : 'ffac537e6cbbf934b08745a378932722df287a53'
52
55
} )
53
56
} )
54
57
55
58
it ( 'Replaces refs/heads in branch name' , async ( ) => {
56
- octokitMock . repos . getBranch . mockRejectedValue ( new HttpError ( ) )
59
+ octokitMock . rest . repos . getBranch . mockRejectedValue ( new HttpError ( ) )
57
60
await createBranch ( githubMock , contextMock , `refs/heads/${ branch } ` )
58
- expect ( octokitMock . git . createRef ) . toHaveBeenCalledWith ( {
61
+ expect ( octokitMock . rest . git . createRef ) . toHaveBeenCalledWith ( {
59
62
ref : 'refs/heads/release-v1' ,
60
63
sha : 'ebb4992dc72451c1c6c99e1cce9d741ec0b5b7d7'
61
64
} )
0 commit comments