Skip to content

Commit

Permalink
Update approvals-satisfied.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sjschmidt93 authored Jul 9, 2024
1 parent 32bf027 commit b7398a9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/helpers/approvals-satisfied.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,4 +514,40 @@ describe('approvalsSatisfied', () => {
});
expect(result).toBe(true);
});

it('should return true when passing comma-seperated list of users and approvals are met', async () => {
mockPagination({
data: [
{
state: 'APPROVED',
user: { login: 'user1' }
}
]
});
const result = await approvalsSatisfied({
users: 'user1,user2',
pull_number: '12345'
});
expect(octokit.pulls.listReviews).toHaveBeenCalledWith({ pull_number: 12345, repo: 'repo', owner: 'owner', page: 1, per_page: 100 });
expect(getRequiredCodeOwnersEntries).not.toHaveBeenCalled();
expect(result).toBe(true);
});

it('should return false when passing comma-seperated list of users and approvals are not met', async () => {
mockPagination({
data: [
{
state: 'APPROVED',
user: { login: 'user3' }
}
]
});
const result = await approvalsSatisfied({
users: 'user1,user2',
pull_number: '12345'
});
expect(octokit.pulls.listReviews).toHaveBeenCalledWith({ pull_number: 12345, repo: 'repo', owner: 'owner', page: 1, per_page: 100 });
expect(getRequiredCodeOwnersEntries).not.toHaveBeenCalled();
expect(result).toBe(false);
});
});

0 comments on commit b7398a9

Please sign in to comment.