From 780b84e881999a1d1e59eb90e6247ee6b1e53f30 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 14 Oct 2016 16:29:47 -0700 Subject: [PATCH 1/4] docs: fix some API docs --- lib/Issue.js | 8 ++++---- lib/Markdown.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Issue.js b/lib/Issue.js index 07fa2b1a..7587658a 100644 --- a/lib/Issue.js +++ b/lib/Issue.js @@ -150,7 +150,7 @@ class Issue extends Requestable { * Get a milestone * @see https://developer.github.com/v3/issues/milestones/#get-a-single-milestone * @param {string} milestone - the id of the milestone to fetch - * @param {Requestable.callback} [cb] - will receive the array of milestones + * @param {Requestable.callback} [cb] - will receive the milestone * @return {Promise} - the promise for the http request */ getMilestone(milestone, cb) { @@ -161,7 +161,7 @@ class Issue extends Requestable { * Create a new milestone * @see https://developer.github.com/v3/issues/milestones/#create-a-milestone * @param {Object} milestoneData - the milestone definition - * @param {Requestable.callback} [cb] - will receive the array of milestones + * @param {Requestable.callback} [cb] - will receive the milestone * @return {Promise} - the promise for the http request */ createMilestone(milestoneData, cb) { @@ -173,7 +173,7 @@ class Issue extends Requestable { * @see https://developer.github.com/v3/issues/milestones/#update-a-milestone * @param {string} milestone - the id of the milestone to edit * @param {Object} milestoneData - the updates to make to the milestone - * @param {Requestable.callback} [cb] - will receive the array of milestones + * @param {Requestable.callback} [cb] - will receive the updated milestone * @return {Promise} - the promise for the http request */ editMilestone(milestone, milestoneData, cb) { @@ -184,7 +184,7 @@ class Issue extends Requestable { * Delete a milestone (this is distinct from closing a milestone) * @see https://developer.github.com/v3/issues/milestones/#delete-a-milestone * @param {string} milestone - the id of the milestone to delete - * @param {Requestable.callback} [cb] - will receive the array of milestones + * @param {Requestable.callback} [cb] - will receive the status * @return {Promise} - the promise for the http request */ deleteMilestone(milestone, cb) { diff --git a/lib/Markdown.js b/lib/Markdown.js index cb84851d..edc346cc 100644 --- a/lib/Markdown.js +++ b/lib/Markdown.js @@ -8,11 +8,11 @@ import Requestable from './Requestable'; /** - * RateLimit allows users to query their rate-limit status + * Renders html from Markdown text */ class Markdown extends Requestable { /** - * construct a RateLimit + * construct a Markdown * @param {Requestable.auth} auth - the credentials to authenticate to GitHub * @param {string} [apiBase] - the base Github API URL * @return {Promise} - the promise for the http request From 75d38df4b84e238edf8ea6c6fc9fab9991c30f03 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 14 Oct 2016 16:30:09 -0700 Subject: [PATCH 2/4] test: simplify test code --- test/organization.spec.js | 6 ++---- test/team.spec.js | 10 ++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/test/organization.spec.js b/test/organization.spec.js index 9d5f75f6..f0044973 100644 --- a/test/organization.spec.js +++ b/test/organization.spec.js @@ -35,7 +35,7 @@ describe('Organization', function() { .then(function({data: members}) { expect(members).to.be.an.array(); - let hasClayReimann = members.reduce((found, member) => member.login === MEMBER_NAME || found, false); + const hasClayReimann = members.some((member) => member.login === MEMBER_NAME); expect(hasClayReimann).to.be.true(); done(); @@ -80,9 +80,7 @@ describe('Organization', function() { it('should list the teams in the organization', function() { return organization.getTeams() .then(({data}) => { - const hasTeam = data.reduce( - (found, member) => member.slug === 'fixed-test-team-1' || found, - false); + const hasTeam = data.some((member) => member.slug === 'fixed-test-team-1'); expect(hasTeam).to.be.true(); }); diff --git a/test/team.spec.js b/test/team.spec.js index 1f712617..11482807 100644 --- a/test/team.spec.js +++ b/test/team.spec.js @@ -56,10 +56,7 @@ describe('Team', function() { // Isolate tests that are based on a fixed team .then(function({data: members}) { expect(members).to.be.an.array(); - let hasTestUser = members.reduce( - (found, member) => member.login === testUser.USERNAME || found, - false - ); + let hasTestUser = members.some((member) => member.login === testUser.USERNAME); expect(hasTestUser).to.be.true(); }); @@ -68,10 +65,7 @@ describe('Team', function() { // Isolate tests that are based on a fixed team it('should get team repos', function() { return team.listRepos() .then(({data}) => { - const hasRepo = data.reduce( - (found, repo) => repo.name === 'fixed-test-repo-1' || found, - false - ); + const hasRepo = data.some((repo) => repo.name === 'fixed-test-repo-1'); expect(hasRepo).to.be.true(); }); From ab311ef2212304ac16128d798abea58d3a8fcacb Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 14 Oct 2016 16:31:46 -0700 Subject: [PATCH 3/4] feat(issues): add get/delete/edit/list for labels --- CHANGELOG.md | 8 ++++++ lib/Issue.js | 45 +++++++++++++++++++++++++++++ test/issue.spec.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 035944d8..4a6098e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## next - ??? + +### Features +* add `Issue.editLabel` +* add `Issue.deleteLabel` +* add `Issue.getLabel` +* add `Issue.listLabels` + ## 2.4.0 - 2016/09/16 ### Features * add `Issue.createLabel` diff --git a/lib/Issue.js b/lib/Issue.js index 7587658a..b906cc98 100644 --- a/lib/Issue.js +++ b/lib/Issue.js @@ -201,6 +201,51 @@ class Issue extends Requestable { createLabel(labelData, cb) { return this._request('POST', `/repos/${this.__repository}/labels`, labelData, cb); } + + /** + * List the labels for the repository + * @see https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository + * @param {Object} options - filtering options + * @param {Requestable.callback} [cb] - will receive the array of labels + * @return {Promise} - the promise for the http request + */ + listLabels(options, cb) { + return this._request('GET', `/repos/${this.__repository}/labels`, options, cb); + } + + /** + * Get a label + * @see https://developer.github.com/v3/issues/labels/#get-a-single-label + * @param {string} label - the name of the label to fetch + * @param {Requestable.callback} [cb] - will receive the label + * @return {Promise} - the promise for the http request + */ + getLabel(label, cb) { + return this._request('GET', `/repos/${this.__repository}/labels/${label}`, null, cb); + } + + /** + * Edit a label + * @see https://developer.github.com/v3/issues/labels/#update-a-label + * @param {string} label - the id of the label to edit + * @param {Object} labelData - the updates to make to the label + * @param {Requestable.callback} [cb] - will receive the updated label + * @return {Promise} - the promise for the http request + */ + editLabel(label, labelData, cb) { + return this._request('PATCH', `/repos/${this.__repository}/labels/${label}`, labelData, cb); + } + + /** + * Delete a label + * @see https://developer.github.com/v3/issues/labels/#delete-a-label + * @param {string} label - the name of the label to delete + * @param {Requestable.callback} [cb] - will receive the status + * @return {Promise} - the promise for the http request + */ + deleteLabel(milestone, cb) { + return this._request('DELETE', `/repos/${this.__repository}/labels/${label}`, null, cb); + } } module.exports = Issue; diff --git a/test/issue.spec.js b/test/issue.spec.js index e3d0bb78..e28bedcd 100644 --- a/test/issue.spec.js +++ b/test/issue.spec.js @@ -69,6 +69,7 @@ describe('Issue', function() { let createdIssueId; let issueCommentId; let createdMilestoneId; + let createdLabel; // 200ms between tests so that Github has a chance to settle beforeEach(function(done) { @@ -160,6 +161,7 @@ describe('Issue', function() { done(); }).catch(done); }); + it('should update a milestone', function(done) { let milestone = { description: 'Version 6 * 7' @@ -174,6 +176,7 @@ describe('Issue', function() { done(); }).catch(done); }); + it('should delete a milestone', function(done) { expect(createdMilestoneId).to.be.a.number(); remoteIssues.deleteMilestone(createdMilestoneId) @@ -182,5 +185,73 @@ describe('Issue', function() { done(); }).catch(done); }); + + it('should create a label', (done) => { + let label = { + name: 'test', + color: '123456', + }; + + remoteIssues.createLabel(label) + .then(({data: createdLabel}) => { + expect(createdLabel).to.have.own('name', label.name); + expect(createdLabel).to.have.own('color', label.color); + + createdLabel = label.name; + done(); + }).catch(done); + }); + + it('should retrieve a single label', (done) => { + let label = { + name: 'test', + color: '123456', + }; + + remoteIssues.getLabel(label.name) + .then(({data: retrievedLabel}) => { + expect(retrievedLabel).to.have.own('name', label.name); + expect(retrievedLabel).to.have.own('color', label.color); + + done(); + }).catch(done); + }); + + + it('should update a label', (done) => { + let label = { + color: '789abc', + }; + + expect(createdLabel).to.be.a.string(); + remoteIssues.editLabel(createdLabel, label) + .then(({data: updatedLabel}) => { + expect(updatedLabel).to.have.own('name', createdLabel); + expect(updatedLabel).to.have.own('color', label.color); + + done(); + }).catch(done); + }); + + it('should list labels', (done) => { + expect(createdLabel).to.be.a.string(); + + remoteIssues.listLabels({}, assertSuccessful(done, function(err, labels) { + expect(labels).to.be.an.array(); + const hasLabel = labels.some((label) => label.name === createdLabel); + expect(hasLabel).to.be.true(); + done(); + })); + }); + + it('should delete a label', (done) => { + expect(createdLabel).to.be.a.string(); + remoteIssues.deleteLabel(createdLabel) + .then(({status}) => { + expect(status).to.equal(204); + done(); + }).catch(done); + }); + }); }); From 1ddba526cfd73df252ce3975e226df0b694efbf4 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 14 Oct 2016 16:55:44 -0700 Subject: [PATCH 4/4] fix: build errors --- lib/Issue.js | 24 ++++----- lib/Repository.js | 3 +- test/issue.spec.js | 119 ++++++++++++++++++++++----------------------- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/lib/Issue.js b/lib/Issue.js index b906cc98..4ea0bd27 100644 --- a/lib/Issue.js +++ b/lib/Issue.js @@ -209,9 +209,9 @@ class Issue extends Requestable { * @param {Requestable.callback} [cb] - will receive the array of labels * @return {Promise} - the promise for the http request */ - listLabels(options, cb) { - return this._request('GET', `/repos/${this.__repository}/labels`, options, cb); - } + listLabels(options, cb) { + return this._request('GET', `/repos/${this.__repository}/labels`, options, cb); + } /** * Get a label @@ -220,9 +220,9 @@ class Issue extends Requestable { * @param {Requestable.callback} [cb] - will receive the label * @return {Promise} - the promise for the http request */ - getLabel(label, cb) { - return this._request('GET', `/repos/${this.__repository}/labels/${label}`, null, cb); - } + getLabel(label, cb) { + return this._request('GET', `/repos/${this.__repository}/labels/${label}`, null, cb); + } /** * Edit a label @@ -232,9 +232,9 @@ class Issue extends Requestable { * @param {Requestable.callback} [cb] - will receive the updated label * @return {Promise} - the promise for the http request */ - editLabel(label, labelData, cb) { - return this._request('PATCH', `/repos/${this.__repository}/labels/${label}`, labelData, cb); - } + editLabel(label, labelData, cb) { + return this._request('PATCH', `/repos/${this.__repository}/labels/${label}`, labelData, cb); + } /** * Delete a label @@ -243,9 +243,9 @@ class Issue extends Requestable { * @param {Requestable.callback} [cb] - will receive the status * @return {Promise} - the promise for the http request */ - deleteLabel(milestone, cb) { - return this._request('DELETE', `/repos/${this.__repository}/labels/${label}`, null, cb); - } + deleteLabel(label, cb) { + return this._request('DELETE', `/repos/${this.__repository}/labels/${label}`, null, cb); + } } module.exports = Issue; diff --git a/lib/Repository.js b/lib/Repository.js index 301e1230..a6de1e3b 100644 --- a/lib/Repository.js +++ b/lib/Repository.js @@ -504,7 +504,8 @@ class Repository extends Requestable { * @return {Promise} - the promise for the http request */ updatePullRequst(number, options, cb) { - log('Deprecated: This method contains a typo and it has been deprecated. It will be removed in next major version. Use updatePullRequest() instead.'); + log('Deprecated: This method contains a typo and it has been deprecated.' + + 'It will be removed in next major version. Use updatePullRequest() instead.'); return this.updatePullRequest(number, options, cb); } diff --git a/test/issue.spec.js b/test/issue.spec.js index e28bedcd..695ac209 100644 --- a/test/issue.spec.js +++ b/test/issue.spec.js @@ -187,71 +187,70 @@ describe('Issue', function() { }); it('should create a label', (done) => { - let label = { - name: 'test', - color: '123456', - }; + let label = { + name: 'test', + color: '123456' + }; + + remoteIssues.createLabel(label) + .then(({data: createdLabel}) => { + expect(createdLabel).to.have.own('name', label.name); + expect(createdLabel).to.have.own('color', label.color); + + createdLabel = label.name; + done(); + }).catch(done); + }); + + it('should retrieve a single label', (done) => { + let label = { + name: 'test', + color: '123456' + }; + + remoteIssues.getLabel(label.name) + .then(({data: retrievedLabel}) => { + expect(retrievedLabel).to.have.own('name', label.name); + expect(retrievedLabel).to.have.own('color', label.color); + + done(); + }).catch(done); + }); - remoteIssues.createLabel(label) - .then(({data: createdLabel}) => { - expect(createdLabel).to.have.own('name', label.name); - expect(createdLabel).to.have.own('color', label.color); + it('should update a label', (done) => { + let label = { + color: '789abc' + }; + + expect(createdLabel).to.be.a.string(); + remoteIssues.editLabel(createdLabel, label) + .then(({data: updatedLabel}) => { + expect(updatedLabel).to.have.own('name', createdLabel); + expect(updatedLabel).to.have.own('color', label.color); + + done(); + }).catch(done); + }); + + it('should list labels', (done) => { + expect(createdLabel).to.be.a.string(); - createdLabel = label.name; + remoteIssues.listLabels({}, assertSuccessful(done, function(err, labels) { + expect(labels).to.be.an.array(); + const hasLabel = labels.some((label) => label.name === createdLabel); + expect(hasLabel).to.be.true(); done(); - }).catch(done); + })); }); - it('should retrieve a single label', (done) => { - let label = { - name: 'test', - color: '123456', - }; - - remoteIssues.getLabel(label.name) - .then(({data: retrievedLabel}) => { - expect(retrievedLabel).to.have.own('name', label.name); - expect(retrievedLabel).to.have.own('color', label.color); - - done(); - }).catch(done); - }); - - - it('should update a label', (done) => { - let label = { - color: '789abc', - }; - - expect(createdLabel).to.be.a.string(); - remoteIssues.editLabel(createdLabel, label) - .then(({data: updatedLabel}) => { - expect(updatedLabel).to.have.own('name', createdLabel); - expect(updatedLabel).to.have.own('color', label.color); - - done(); - }).catch(done); - }); - - it('should list labels', (done) => { - expect(createdLabel).to.be.a.string(); - - remoteIssues.listLabels({}, assertSuccessful(done, function(err, labels) { - expect(labels).to.be.an.array(); - const hasLabel = labels.some((label) => label.name === createdLabel); - expect(hasLabel).to.be.true(); - done(); - })); - }); - - it('should delete a label', (done) => { - expect(createdLabel).to.be.a.string(); - remoteIssues.deleteLabel(createdLabel) - .then(({status}) => { - expect(status).to.equal(204); - done(); - }).catch(done); - }); + it('should delete a label', (done) => { + expect(createdLabel).to.be.a.string(); + remoteIssues.deleteLabel(createdLabel) + .then(({status}) => { + expect(status).to.equal(204); + done(); + }).catch(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