From a37e56fc2663329e9fd4ebcb9fca160d654e506e Mon Sep 17 00:00:00 2001 From: alexcanessa Date: Thu, 12 Oct 2017 23:50:11 +0100 Subject: [PATCH] Add options to the listReleases and listTags function and fix markdown test --- lib/Repository.js | 10 ++++++---- test/markdown.spec.js | 2 +- test/repository.spec.js | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/Repository.js b/lib/Repository.js index d338b261..a194486c 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -78,11 +78,12 @@ class Repository extends Requestable { /** * List the tags on a repository * @see https://developer.github.com/v3/repos/#list-tags + * @param {Object} options - pagination for the list * @param {Requestable.callback} [cb] - will receive the tag data * @return {Promise} - the promise for the http request */ - listTags(cb) { - return this._request('GET', `/repos/${this.__fullname}/tags`, null, cb); + listTags(options, cb = options) { + return this._request('GET', `/repos/${this.__fullname}/tags`, options !== 'function' && options, cb); } /** @@ -793,11 +794,12 @@ class Repository extends Requestable { /** * Get information about all releases * @see https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository + * @param {Object} options - pagination for the list * @param {Requestable.callback} cb - will receive the release information * @return {Promise} - the promise for the http request */ - listReleases(cb) { - return this._request('GET', `/repos/${this.__fullname}/releases`, null, cb); + listReleases(options, cb = options) { + return this._request('GET', `/repos/${this.__fullname}/releases`, options !== 'function' && options, cb); } /** diff --git a/test/markdown.spec.js b/test/markdown.spec.js index eef9fe08..06288944 100644 --- a/test/markdown.spec.js +++ b/test/markdown.spec.js @@ -37,7 +37,7 @@ describe('Markdown', function() { }; markdown.render(options) .then(function({data: html}) { - expect(html).to.be('

Hello world github/linguist#1 cool, and #1!

'); // eslint-disable-line + expect(html).to.be('

Hello world github/linguist#1 cool, and #1!

'); // eslint-disable-line done(); }).catch(done); }); diff --git a/test/repository.spec.js b/test/repository.spec.js index ef5101cf..45789d66 100644 --- a/test/repository.spec.js +++ b/test/repository.spec.js @@ -459,6 +459,11 @@ describe('Repository', function() { }); it('should list tags on repo', function(done) { + const options = { + per_page: 30 //eslint-disable-line + }; + + remoteRepo.listTags(options, assertSuccessful(done)); remoteRepo.listTags(assertSuccessful(done)); }); @@ -628,6 +633,15 @@ describe('Repository', function() { }); it('should read all releases', function(done) { + const options = { + per_page: 30 //eslint-disable-line + }; + + remoteRepo.listReleases(options, assertSuccessful(done, function(err, releases) { + expect(releases).to.be.an.array(); + done(); + })); + remoteRepo.listReleases(assertSuccessful(done, function(err, releases) { expect(releases).to.be.an.array(); done();