Skip to content

Commit 16b1fc4

Browse files
committed
test: add tooltip utils empty fallback tests
1 parent e3369ea commit 16b1fc4

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)