fix: VSTS - add reviewer once even if multiple teams (#1259)

Closes #1258
This commit is contained in:
JYC 2017-12-02 20:22:03 +01:00 committed by Rhys Arkins
parent 62fd3563a5
commit 560bf727c3
2 changed files with 11 additions and 4 deletions

View file

@ -510,8 +510,13 @@ async function addReviewers(prNo, reviewers) {
members.forEach(listMembers => {
listMembers.forEach(m => {
reviewers.forEach(r => {
if (r === m.displayName || r === m.uniqueName) {
ids.push({ id: m.id, name: r });
if (
r.toLowerCase() === m.displayName.toLowerCase() ||
r.toLowerCase() === m.uniqueName.toLowerCase()
) {
if (ids.filter(c => c.id === m.id).length === 0) {
ids.push({ id: m.id, name: r });
}
}
});
});

View file

@ -676,10 +676,12 @@ describe('platform/vsts', () => {
}));
vstsApi.getCoreApi.mockImplementation(() => ({
getTeams: jest.fn(() => [{ id: 3 }, { id: 4 }]),
getTeamMembers: jest.fn(() => [{ displayName: 'jyc' }]),
getTeamMembers: jest.fn(() => [
{ displayName: 'jyc', uniqueName: 'jyc', id: 123 },
]),
}));
await vsts.addReviewers(123, ['test@bonjour.fr', 'jyc']);
expect(vstsApi.gitApi.mock.calls.length).toBe(5);
expect(vstsApi.gitApi.mock.calls.length).toBe(4);
});
// to become async?