Skip to content

Commit 56c9f59

Browse files
committed
test(github): add coverage for getFullDashboardData with empty repos
1 parent 4e27e7f commit 56c9f59

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

lib/github.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,38 @@ describe('GitHub API cache behavior', () => {
484484

485485
expect(fetch).toHaveBeenCalledTimes(2);
486486
});
487+
488+
it('handles a new account with no public repos correctly', async () => {
489+
vi.mocked(fetch).mockImplementation(async (url: any) => {
490+
if (typeof url === 'string' && url.includes('/users/octocat/repos')) {
491+
return mockResponse([]);
492+
}
493+
if (typeof url === 'string' && url.includes('/users/octocat')) {
494+
return mockResponse({
495+
login: 'octocat',
496+
name: 'The Octocat',
497+
avatar_url: 'avatar.png',
498+
public_repos: 0,
499+
followers: 0,
500+
following: 0,
501+
created_at: '2024-01-01T00:00:00Z',
502+
bio: null,
503+
location: null,
504+
});
505+
}
506+
return mockResponse({
507+
data: {
508+
user: { contributionsCollection: { contributionCalendar: mockCalendar } },
509+
},
510+
});
511+
});
512+
513+
const result = await getFullDashboardData('octocat');
514+
515+
expect(result.languages).toEqual([]);
516+
expect(result.profile.stats.stars).toBe(0);
517+
expect(result.profile.developerScore).toBeGreaterThanOrEqual(0);
518+
});
487519
});
488520
describe('generateAchievements', () => {
489521
it('marks contribution milestones correctly', () => {

0 commit comments

Comments
 (0)