Skip to content

Commit

Permalink
Update test to take into account new comment feature
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Feb 8, 2021
1 parent 0db6367 commit 3e4855b
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe( 'firstTimeContributorLabel', () => {
},
issues: {
addLabels: jest.fn(),
createComment: jest.fn(),
},
};

Expand All @@ -43,6 +44,7 @@ describe( 'firstTimeContributorLabel', () => {
author: 'ghost',
} );
expect( octokit.issues.addLabels ).not.toHaveBeenCalled();
expect( octokit.issues.createComment ).not.toHaveBeenCalled();
} );

it( 'adds the First Time Contributor label if the user has no commits', async () => {
Expand All @@ -56,9 +58,16 @@ describe( 'firstTimeContributorLabel', () => {
},
issues: {
addLabels: jest.fn(),
createComment: jest.fn(),
},
};

const expectedComment =
':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ghost' +
"!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," +
'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' +
'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.';

await firstTimeContributorLabel( payload, octokit );

expect( octokit.repos.listCommits ).toHaveBeenCalledWith( {
Expand All @@ -72,5 +81,11 @@ describe( 'firstTimeContributorLabel', () => {
issue_number: 123,
labels: [ 'First-time Contributor' ],
} );
expect( octokit.issues.createComment ).toHaveBeenCalledWith( {
owner: 'WordPress',
repo: 'gutenberg',
issue_number: 123,
body: expectedComment,
} );
} );
} );

0 comments on commit 3e4855b

Please sign in to comment.