-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow commands in review submissions (#149)
- Loading branch information
Showing
12 changed files
with
187 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export function extractBody(payload) { | ||
if (payload.review) { | ||
return payload.review.body; | ||
} | ||
return payload.comment.body; | ||
} | ||
|
||
export function extractHtmlUrl(payload) { | ||
if (payload.review) { | ||
return payload.pull_request.html_url; | ||
} | ||
return payload.issue.html_url; | ||
} | ||
|
||
export function extractLabelableId(payload) { | ||
if (payload.review) { | ||
return payload.pull_request.node_id; | ||
} | ||
|
||
return payload.issue.node_id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { | ||
extractBody, | ||
extractHtmlUrl, | ||
extractLabelableId, | ||
} from "./comment-extractor.js"; | ||
|
||
describe("extractors", () => { | ||
describe("extractBody", () => { | ||
test("is a review", () => { | ||
expect( | ||
extractBody({ | ||
review: { | ||
body: "review body", | ||
}, | ||
}) | ||
).toEqual("review body"); | ||
}); | ||
|
||
test("is an issue", () => { | ||
expect( | ||
extractBody({ | ||
comment: { | ||
body: "comment body", | ||
}, | ||
}) | ||
).toEqual("comment body"); | ||
}); | ||
}); | ||
|
||
describe("extractHtmlUrl", () => { | ||
test("is a review", () => { | ||
expect( | ||
extractHtmlUrl({ | ||
review: { | ||
body: "review body", | ||
}, | ||
pull_request: { | ||
html_url: "https://github.com/some-org/some-repo/pull/1", | ||
}, | ||
}) | ||
).toEqual("https://github.com/some-org/some-repo/pull/1"); | ||
}); | ||
|
||
test("is an issue", () => { | ||
expect( | ||
extractHtmlUrl({ | ||
issue: { | ||
html_url: "https://github.com/some-org/some-repo/issue/1", | ||
}, | ||
}) | ||
).toEqual("https://github.com/some-org/some-repo/issue/1"); | ||
}); | ||
}); | ||
|
||
describe("extractLabelableId", () => { | ||
test("is a review", () => { | ||
expect( | ||
extractLabelableId({ | ||
review: { | ||
body: "review body", | ||
}, | ||
pull_request: { | ||
node_id: "PR_aaaaaa", | ||
}, | ||
}) | ||
).toEqual("PR_aaaaaa"); | ||
}); | ||
|
||
test("is an issue", () => { | ||
expect( | ||
extractLabelableId({ | ||
issue: { | ||
node_id: "PR_abcdefgh", | ||
}, | ||
}) | ||
).toEqual("PR_abcdefgh"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.