Skip to content

Commit b377502

Browse files
authored
test(github): add coverage for getFullDashboardData with empty repos (JhaSourav07#756)
2 parents 39b37f5 + 56c9f59 commit b377502

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
@@ -485,6 +485,38 @@ describe('GitHub API cache behavior', () => {
485485

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

0 commit comments

Comments
 (0)