Skip to content

Commit

Permalink
add test to ensure assignees are passed in as strings, fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
imsky committed Mar 2, 2017
1 parent 04b9d49 commit fb4e821
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 23 additions & 1 deletion test/review-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit fb4e821

Please sign in to comment.