Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
fix(pr-triage.js): fix approved pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
sotayamashita committed Jun 17, 2018
1 parent fe0e613 commit 9a53406
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/pr-triage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PRTriage {
// see https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review
static get GH_REVIEW_STATE() {
return Object.freeze({
APPROVE: "APPROVE",
APPROVED: "APPROVED",
CHANGES_REQUESTED: "CHANGES_REQUESTED",
COMMENT: "COMMENT"
});
Expand Down Expand Up @@ -56,16 +56,16 @@ class PRTriage {
if (reviews.length === 0) {
return PRTriage.STATE.UNREVIED;
} else {
const ChangeRequestedReviews = reviews.filter(
const changeRequestedReviews = reviews.filter(
review => review.state === PRTriage.GH_REVIEW_STATE.CHANGES_REQUESTED
);
const approvedReviews = reviews.filter(
review => review.state === PRTriage.GH_REVIEW_STATE.APPROVE
review => review.state === PRTriage.GH_REVIEW_STATE.APPROVED
);

if (ChangeRequestedReviews.length > 0) {
if (changeRequestedReviews.length > 0) {
return PRTriage.STATE.CHANGES_REQUESTED;
} else if (reviews.lnegth === approvedReviews.length) {
} else if (reviews.length === approvedReviews.length) {
return PRTriage.STATE.APPROVED;
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"data": [{
"id": 1,
"user": { "id": 1 },
"state": "APPROVE",
"state": "APPROVED",
"submitted_at": "2018-01-06T08:28:10Z",
"commit_id": "head"
}, {
"id": 1,
"user": { "id": 2 },
"state": "APPROVE",
"state": "APPROVED",
"submitted_at": "2018-01-06T08:28:10Z",
"commit_id": "head"
}]
Expand Down
4 changes: 2 additions & 2 deletions test/pr-triage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("PRTriage", () => {
*/
describe("GH REVIEW STATE", () => {
expect(PRTriage.GH_REVIEW_STATE).toEqual({
APPROVE: "APPROVE",
APPROVED: "APPROVED",
CHANGES_REQUESTED: "CHANGES_REQUESTED",
COMMENT: "COMMENT"
});
Expand Down Expand Up @@ -98,7 +98,7 @@ describe("PRTriage", () => {
klass.pullRequest =
payload["pull_request"]["with"]["unreviewed_label"]["data"];
const result = await subject();
expect(result).toEqual(PRTriage.STATE.APPROVE);
expect(result).toEqual(PRTriage.STATE.APPROVED);
});
});
}); // _getState
Expand Down

0 comments on commit 9a53406

Please sign in to comment.