From d53018292e58c68dba1875edb88d8bc7c7f6c29c Mon Sep 17 00:00:00 2001 From: Jed Fonner Date: Fri, 25 Nov 2016 13:38:48 -0500 Subject: [PATCH] Adds method for listing review comments --- lib/Repository.js | 11 +++++++++++ test/repository.spec.js | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/Repository.js b/lib/Repository.js index 301e1230..b99c8d44 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -803,6 +803,17 @@ class Repository extends Requestable { mergePullRequest(number, options, cb) { return this._request('PUT', `/repos/${this.__fullname}/pulls/${number}/merge`, options, cb); } + + /** + * List review comments on an pull request + * @see https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request + * @param {number|string} number - the number of the pull request to get review comments from + * @param {Requestable.callback} [cb] - will receive the comments + * @return {Promise} - the promise for the http request + */ + listPullRequestReviewComments(number, cb) { + return this._request('GET', `/repos/${this.__fullname}/pulls/${number}/comments`, null, cb); + } } module.exports = Repository; diff --git a/test/repository.spec.js b/test/repository.spec.js index f747878d..1b08a46d 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -240,6 +240,16 @@ describe('Repository', function() { done(); })); }); + + it('should list review comments', function(done) { + const repo = github.getRepo('michael', 'github'); + + repo.listPullRequestReviewComments(401, assertSuccessful(done, function(err, reviewComments) { + expect(reviewComments).to.be.an.array(); + //expect(reviewComments[0]).to.have.own('body', 'Comment test'); //TODO: Need to establish a test PR with test review comments + done(); + })); + }); }); describe('creating/modifiying', function() {