From 9671d24ef3c22431bdf90c2f5b33754c02b6e6e1 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Tue, 11 Jul 2017 12:40:29 +0900 Subject: [PATCH 1/4] Add addLabel() to add a label to an issue --- lib/Issue.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Issue.js b/lib/Issue.js index c0151b5f..172cca56 100644 --- a/lib/Issue.js +++ b/lib/Issue.js @@ -246,6 +246,18 @@ class Issue extends Requestable { deleteLabel(label, cb) { return this._request('DELETE', `/repos/${this.__repository}/labels/${label}`, null, cb); } + + /** + * Add label 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 {string} label - the name of the label to add to the issue + * @param {Requestable.callback} [cb] - will receive the status + * @return {Promise} - the promise for the http request + */ + addLabel(issue, label, cb) { + return this._request('POST', `/repos/${this.__repository}/issues/${issue}/labels`, label, cb); + } } module.exports = Issue; From 01a48425873e283c4c63e5a4916a7d0b5a91876c Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Tue, 11 Jul 2017 12:42:04 +0900 Subject: [PATCH 2/4] Add removeLabel() to remove a label from an issue --- lib/Issue.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Issue.js b/lib/Issue.js index 172cca56..82ca1675 100644 --- a/lib/Issue.js +++ b/lib/Issue.js @@ -258,6 +258,18 @@ class Issue extends Requestable { addLabel(issue, label, cb) { return this._request('POST', `/repos/${this.__repository}/issues/${issue}/labels`, label, cb); } + + /** + * Add label to 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; From afe6fec1c499a27645fe7e09dbcc4e48c34fe3c1 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Tue, 11 Jul 2017 21:31:42 +0900 Subject: [PATCH 3/4] Update comments --- lib/Issue.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Issue.js b/lib/Issue.js index 82ca1675..bce20790 100644 --- a/lib/Issue.js +++ b/lib/Issue.js @@ -248,10 +248,10 @@ class Issue extends Requestable { } /** - * Add label to an issue + * Add a label 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 {string} label - the name of the label to add to the issue + * @param {array} label - the names of the label to add to the issue * @param {Requestable.callback} [cb] - will receive the status * @return {Promise} - the promise for the http request */ @@ -260,7 +260,7 @@ class Issue extends Requestable { } /** - * Add label to an issue + * 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 From 4741704621a1ef70a9c5d97cde65cc0bbba79a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BRAMILLE?= <2752200+oktapodia@users.noreply.github.com> Date: Fri, 14 Aug 2020 10:37:58 +0100 Subject: [PATCH 4/4] Add tests --- lib/Issue.js | 8 ++++---- test/issue.spec.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/Issue.js b/lib/Issue.js index bce20790..8a76686f 100644 --- a/lib/Issue.js +++ b/lib/Issue.js @@ -248,15 +248,15 @@ class Issue extends Requestable { } /** - * Add a label to an issue + * 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} label - the names of the label to add to the issue + * @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 */ - addLabel(issue, label, cb) { - return this._request('POST', `/repos/${this.__repository}/issues/${issue}/labels`, label, cb); + setLabels(issue, labels, cb) { + return this._request('POST', `/repos/${this.__repository}/issues/${issue}/labels`, labels, cb); } /** 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(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy