diff --git a/lib/Issue.js b/lib/Issue.js index c0151b5f..8a76686f 100644 --- a/lib/Issue.js +++ b/lib/Issue.js @@ -246,6 +246,30 @@ class Issue extends Requestable { deleteLabel(label, cb) { return this._request('DELETE', `/repos/${this.__repository}/labels/${label}`, null, cb); } + + /** + * Set labels to an issue + * @see https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue + * @param {number} issue - the id of the issue to comment on + * @param {array} labels - the names of the labels to add to the issue + * @param {Requestable.callback} [cb] - will receive the status + * @return {Promise} - the promise for the http request + */ + setLabels(issue, labels, cb) { + return this._request('POST', `/repos/${this.__repository}/issues/${issue}/labels`, labels, cb); + } + + /** + * Remove a label from an issue + * @see https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue + * @param {number} issue - the id of the issue to comment on + * @param {string} label - the name of the label to remove to the issue + * @param {Requestable.callback} [cb] - will receive the status + * @return {Promise} - the promise for the http request + */ + removeLabel(issue, label, cb) { + return this._request('DELETE', `/repos/${this.__repository}/issues/${issue}/labels/${label}`, null, cb); + } } module.exports = Issue; diff --git a/test/issue.spec.js b/test/issue.spec.js index 274ca793..47d2d939 100644 --- a/test/issue.spec.js +++ b/test/issue.spec.js @@ -163,6 +163,23 @@ describe('Issue', function() { it('should delete issue comment', function(done) { remoteIssues.deleteIssueComment(issueCommentId, assertSuccessful(done, function(err, response) { + expect(response.).to.be.true(); + + done(); + })); + }); + + it('should set labels to an issue', function(done) { + const labelName = 'test label' + remoteIssues.setLabels(issueCommentId, [labelName], assertSuccessful(done, function(err, response) { + expect(response[0]).to.have.own('name', labelName); + + done(); + })); + }); + + it('should remove labels to an issue', function(done) { + remoteIssues.removeLabel(issueCommentId, 'test label', assertSuccessful(done, function(err, response) { expect(response).to.be.true(); done();
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: