-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It bothered me having all these functions distrubted throughout the repo. They now all live in a 'utils' folder. I have started a folder for functions that relate to the github API. I have renamed the 'utils.js' file to 'index.js' now that it lives within a utils dir.
- Loading branch information
rich
committed
Sep 13, 2024
1 parent
bb2f2ed
commit d331b2d
Showing
7 changed files
with
39 additions
and
34 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
dataScripts/fetchAllRepos.js → utils/githubApi/fetchAllRepos.js
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,5 @@ | ||
export const getOpenPRsForRepo = ({ octokit, repository }) => { | ||
return octokit.request(repository.pulls_url).then(handlePrsApiResponse); | ||
}; | ||
|
||
export const handlePrsApiResponse = ({ data }) => data?.length || 0; |
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,13 @@ | ||
import { describe, it } from "node:test"; | ||
import expect from "node:assert"; | ||
import { handlePrsApiResponse } from "./fetchOpenPrs.js"; | ||
|
||
describe("handlePrsApiResponse", () => { | ||
it("returns the length of the array containing PRs", () => { | ||
expect.equal(handlePrsApiResponse({ data: [1, 2, 3] }), 3); | ||
}); | ||
|
||
it("returns 0 if there are no open PRs", () => { | ||
expect.equal(handlePrsApiResponse({ data: undefined }), 0); | ||
}); | ||
}); |
File renamed without changes.
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