Skip to content

Commit 4ce1aec

Browse files
committed
test: add coverage for organization repo fetching
1 parent e77ca71 commit 4ce1aec

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/api/github.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ describe("fetchLanguageData", () => {
128128
const result = await fetchLanguageData();
129129
expect(result).toEqual({ Python: 500 });
130130
});
131+
132+
it("fetches from organizations", async () => {
133+
vi.unstubAllEnvs();
134+
vi.stubEnv('GITHUB_ORGS', 'test-org');
135+
136+
const orgRepos = [
137+
{ name: "org-repo", fork: false, full_name: "test-org/org-repo" }
138+
];
139+
140+
global.fetch
141+
.mockResolvedValueOnce({ ok: true, json: async () => orgRepos })
142+
.mockResolvedValueOnce({ ok: true, json: async () => ({ TypeScript: 4000 }) })
143+
144+
const result = await fetchLanguageData();
145+
146+
expect(global.fetch).toHaveBeenCalledWith(
147+
'https://api.github.com/orgs/test-org/repos?per_page=100'
148+
);
149+
expect(result).toEqual({ TypeScript: 4000 });
150+
});
131151
});
132152

133153
describe("processLanguageData", () => {

0 commit comments

Comments
 (0)