Skip to content

Commit c64e010

Browse files
authored
test: add tooltip utils empty fallback tests (JhaSourav07#3310)
## Description Fixes JhaSourav07#2633 Added isolated Vitest coverage for `components/dashboard/tooltipUtils.ts` empty and fallback edge cases. ## Pillar - [ ] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [x] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview Not applicable β€” test-only change. ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [ ] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 12136fb + 16b1fc4 commit c64e010

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { describe, expect, it } from 'vitest';
2+
import {
3+
formatTooltipDate,
4+
getActivityInsight,
5+
getContributionLabel,
6+
getLocalActiveStreak,
7+
getStreakLabel,
8+
} from './tooltipUtils';
9+
10+
describe('tooltipUtils empty fallback behavior', () => {
11+
it('returns original value for empty or invalid tooltip dates', () => {
12+
expect(formatTooltipDate('')).toBe('');
13+
expect(formatTooltipDate('invalid-date')).toBe('invalid-date');
14+
});
15+
16+
it('formats zero contributions with plural fallback label', () => {
17+
expect(getContributionLabel(0)).toBe('0 contributions');
18+
});
19+
20+
it('returns no activity insight for zero count without intensity', () => {
21+
expect(getActivityInsight(0)).toBe('No activity recorded');
22+
});
23+
24+
it('returns zero local active streak for empty activity data', () => {
25+
expect(getLocalActiveStreak([], 0)).toBe(0);
26+
});
27+
28+
it('returns no active streak label for zero or negative streaks', () => {
29+
expect(getStreakLabel(0)).toBe('No active streak');
30+
expect(getStreakLabel(-1)).toBe('No active streak');
31+
});
32+
});

0 commit comments

Comments
Β (0)