|
5 | 5 | fetchUserRepos, |
6 | 6 | getFullDashboardData, |
7 | 7 | generateAchievements, |
| 8 | + buildCommitClock, |
8 | 9 | clearGitHubApiCacheForTests, |
9 | 10 | GITHUB_CACHE_TTL_MS, |
10 | 11 | validateGitHubUsername, |
@@ -709,6 +710,46 @@ describe('buildInsights', () => { |
709 | 710 | }); |
710 | 711 | }); |
711 | 712 |
|
| 713 | +describe('buildCommitClock', () => { |
| 714 | + it('counts commits only on Sunday when all days are Sunday', () => { |
| 715 | + const result = buildCommitClock([ |
| 716 | + { date: '2024-01-07', contributionCount: 3 }, |
| 717 | + { date: '2024-01-14', contributionCount: 2 }, |
| 718 | + ]); |
| 719 | + |
| 720 | + expect(result).toHaveLength(7); |
| 721 | + expect(result[0].commits).toBeGreaterThan(0); |
| 722 | + expect(result.slice(1).every((item) => item.commits === 0)).toBe(true); |
| 723 | + }); |
| 724 | + |
| 725 | + it('returns 7 days with zero commits for empty input', () => { |
| 726 | + const result = buildCommitClock([]); |
| 727 | + |
| 728 | + expect(result).toHaveLength(7); |
| 729 | + expect(result.every((item) => item.commits === 0)).toBe(true); |
| 730 | + }); |
| 731 | + |
| 732 | + it('always returns exactly 7 items', () => { |
| 733 | + const result = buildCommitClock([{ date: '2024-01-07', contributionCount: 1 }]); |
| 734 | + |
| 735 | + expect(result).toHaveLength(7); |
| 736 | + }); |
| 737 | + |
| 738 | + it('uses weekday labels from Sunday to Saturday', () => { |
| 739 | + const result = buildCommitClock([]); |
| 740 | + |
| 741 | + expect(result.map((item) => item.day)).toEqual([ |
| 742 | + 'Sun', |
| 743 | + 'Mon', |
| 744 | + 'Tue', |
| 745 | + 'Wed', |
| 746 | + 'Thu', |
| 747 | + 'Fri', |
| 748 | + 'Sat', |
| 749 | + ]); |
| 750 | + }); |
| 751 | +}); |
| 752 | + |
712 | 753 | // ---------- EPIC ENHANCEMENT TESTS ---------- |
713 | 754 |
|
714 | 755 | describe('fetchOrgMembers', () => { |
|
0 commit comments