From 3f9e5a2e4644c1ea8ff3ecaaae6d051f8372f8ff Mon Sep 17 00:00:00 2001 From: Simon Barendse Date: Tue, 6 Jun 2017 23:29:28 +0200 Subject: [PATCH] feature(repository): add listPullRequestReviews (#454) --- lib/Repository.js | 11 +++++++++++ test/repository.spec.js | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/Repository.js b/lib/Repository.js index d338b261..76227267 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -119,6 +119,17 @@ class Repository extends Requestable { return this._request('GET', `/repos/${this.__fullname}/pulls/${number}/files`, null, cb); } + /** + * List the reviews of a specific pull request + * @see https://developer.github.com/v3/pulls/reviews/ + * @param {number|string} number - the PR you wish to fetch + * @param {Requestable.callback} [cb] - will receive the list of reviews from the API + * @return {Promise} - the promise for the http request + */ + listPullRequestReviews(number, cb) { + return this._request('GET', `/repos/${this.__fullname}/pulls/${number}/reviews`, null, cb); + } + /** * Compare two branches/commits/repositories * @see https://developer.github.com/v3/repos/commits/#compare-two-commits diff --git a/test/repository.spec.js b/test/repository.spec.js index ef5101cf..c1d16dec 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -260,6 +260,15 @@ describe('Repository', function() { done(); })); }); + + it('should list pullrequest reviews', function(done) { + remoteRepo.listPullRequestReviews(454, assertSuccessful(done, function(err, reviews) { + expect(reviews).to.be.an.array(); + expect(reviews[0]).to.have.own('body', 'Please add tests for this'); + + done(); + })); + }); }); describe('creating/modifiying', function() {