@@ -10,8 +10,8 @@ const events = require('./events')
1010// Constants
1111const baseStatus = {
1212 sha : '123456789' ,
13- repo : 'test-commitlint-bot ' ,
14- owner : 'ahmed-taj ' ,
13+ repo : 'repo ' ,
14+ owner : 'user ' ,
1515 context : 'commitlint-bot' ,
1616 target_url : 'http://npm.im/@commitlint/config-angular#problems'
1717}
@@ -31,20 +31,56 @@ describe('commitlint-bot', () => {
3131 robot . auth = ( ) => Promise . resolve ( github )
3232 } )
3333
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 ( ) => {
4342 await robot . receive ( events . opened )
4443 expect ( github . repos . createStatus ) . toHaveBeenCalledWith ( pending )
45- // Updated PR
44+ } )
45+
46+ it ( 'works with updated PRs' , async ( ) => {
4647 await robot . receive ( events . synchronize )
4748 expect ( github . repos . createStatus ) . toHaveBeenCalledWith ( pending )
4849 } )
4950 } )
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+ } )
5086} )
0 commit comments