Skip to content

Commit

Permalink
Add options to the listReleases and listTags function and fix markdow…
Browse files Browse the repository at this point in the history
…n test
  • Loading branch information
alexcanessa committed Oct 12, 2017
1 parent 24223f7 commit a37e56f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/Repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Markdown', function() {
};
markdown.render(options)
.then(function({data: html}) {
expect(html).to.be('<p>Hello world <a href="https://github.com/github/linguist/issues/1" class="issue-link js-issue-link" data-url="https://github.com/github/linguist/issues/1" data-id="1012654" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">github/linguist#1</a> <strong>cool</strong>, and <a href="https://github.com/gollum/gollum/issues/1" class="issue-link js-issue-link" data-url="https://github.com/gollum/gollum/issues/1" data-id="183433" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">#1</a>!</p>'); // eslint-disable-line
expect(html).to.be('<p>Hello world <a href="https://github.com/github/linguist/issues/1" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="1012654" data-permission-text="Issue title is private" data-url="https://github.com/github/linguist/issues/1">github/linguist#1</a> <strong>cool</strong>, and <a href="https://github.com/gollum/gollum/issues/1" class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="183433" data-permission-text="Issue title is private" data-url="https://github.com/gollum/gollum/issues/1">#1</a>!</p>'); // eslint-disable-line
done();
}).catch(done);
});
Expand Down
14 changes: 14 additions & 0 deletions test/repository.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit a37e56f

Please sign in to comment.