diff --git a/src/github/index.js b/src/github/index.js index 6c0abc3..036e376 100644 --- a/src/github/index.js +++ b/src/github/index.js @@ -140,6 +140,14 @@ function getBlameForCommitFile (resource) { } function assignUsersToResource (resource, assignees) { + assignees = assignees || []; + + for(var i = 0; i < assignees.length; i++) { + if (typeof assignees[i] !== 'string') { + throw Error('Assignees must be specified as strings'); + } + } + return github.issues.addAssigneesToIssue({ 'owner': resource.owner, 'repo': resource.repo, diff --git a/test/review-test.js b/test/review-test.js index ef2275f..2c9e1be 100644 --- a/test/review-test.js +++ b/test/review-test.js @@ -270,7 +270,29 @@ describe('(unit)', function () { }); it('#getBlameForCommitFile'); - it('#assignUsersToResource'); + + describe('#assignUsersToResource', function () { + it('works correctly', function () { + ghapi.post('/repos/OWNER/REPO/issues/1/assignees').reply(200); + + return github.assignUsersToResource({ + 'owner': 'OWNER', + 'repo': 'REPO', + 'number': '1' + }, ['test']); + }); + + it('fails with non-text assignees', function () { + (function () { + github.assignUsersToResource({ + 'owner': 'OWNER', + 'repo': 'REPO', + 'number': '1' + }, [{}]); + }).should.throw(Error, 'Assignees must be specified as strings'); + }); + }); + it('#postPullRequestComment'); it('#getRepoFile', function () {