@@ -10,8 +10,8 @@ const events = require('./events')
10
10
// Constants
11
11
const baseStatus = {
12
12
sha : '123456789' ,
13
- repo : 'test-commitlint-bot ' ,
14
- owner : 'ahmed-taj ' ,
13
+ repo : 'repo ' ,
14
+ owner : 'user ' ,
15
15
context : 'commitlint-bot' ,
16
16
target_url : 'http://npm.im/@commitlint/config-angular#problems'
17
17
}
@@ -31,20 +31,56 @@ describe('commitlint-bot', () => {
31
31
robot . auth = ( ) => Promise . resolve ( github )
32
32
} )
33
33
34
- describe ( 'update status to pending' , ( ) => {
35
- it ( 'calls createStatus with "pending"' , async ( ) => {
36
- const pending = {
37
- ...baseStatus ,
38
- state : 'pending' ,
39
- description : 'Waiting for the status to be reported'
40
- }
41
- // Simulates delivery of a payload
42
- // New PR
34
+ describe ( 'updates status to pending' , ( ) => {
35
+ const pending = {
36
+ ...baseStatus ,
37
+ state : 'pending' ,
38
+ description : 'Waiting for the status to be reported'
39
+ }
40
+
41
+ it ( 'works with new PRs' , async ( ) => {
43
42
await robot . receive ( events . opened )
44
43
expect ( github . repos . createStatus ) . toHaveBeenCalledWith ( pending )
45
- // Updated PR
44
+ } )
45
+
46
+ it ( 'works with updated PRs' , async ( ) => {
46
47
await robot . receive ( events . synchronize )
47
48
expect ( github . repos . createStatus ) . toHaveBeenCalledWith ( pending )
48
49
} )
49
50
} )
51
+
52
+ describe ( 'gets the list of commits for PRs' , ( ) => {
53
+ const info = { repo : 'repo' , owner : 'user' , number : 1 }
54
+
55
+ it ( 'works with new PRs' , async ( ) => {
56
+ await robot . receive ( events . opened )
57
+ expect ( github . pullRequests . getCommits ) . toHaveBeenCalledWith ( info )
58
+ } )
59
+
60
+ it ( 'works with updated PRs' , async ( ) => {
61
+ await robot . receive ( events . synchronize )
62
+ expect ( github . pullRequests . getCommits ) . toHaveBeenCalledWith ( info )
63
+ } )
64
+ } )
65
+
66
+ describe ( 'sends success when messages are valid' , ( ) => {
67
+ const success = {
68
+ ...baseStatus ,
69
+ state : 'success' ,
70
+ // description: 'found 0 problems, 0 warnings'
71
+ description : 'ok'
72
+ }
73
+
74
+ it ( 'works with new PRs' , async ( ) => {
75
+ // Prepare
76
+ // github = githubMock(['fix: me'])
77
+ // robot.auth = () => Promise.resolve(github)
78
+ await robot . receive ( events . opened )
79
+ expect ( github . repos . createStatus ) . toHaveBeenCalledWith ( success )
80
+ } )
81
+ it ( 'works with updated PRs' , async ( ) => {
82
+ await robot . receive ( events . synchronize )
83
+ expect ( github . repos . createStatus ) . toHaveBeenCalledWith ( success )
84
+ } )
85
+ } )
50
86
} )
0 commit comments