Skip to content

Commit 4fda518

Browse files
authored
test(heatmapUtils): add full getIntensityColor coverage (JhaSourav07#1169)
## Description - Added unit tests for `getIntensityColor` - Covered intensity levels `0` to `4` - Added fallback tests for out-of-range values `99` and `-1` Fixes # (issue number) Fixes JhaSourav07#1007 ## Type of change - [x] Tests ## Testing - [x] `npm test -- components/dashboard/heatmapUtils.test.ts` - [x] `npm run format` - [x] `npm run lint ## 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. This PR only adds unit tests and does not change the UI or SVG output. ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [ ] 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. - [ ] 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. ## Notes This PR only adds unit tests, so visual preview, localhost API testing, README updates, and SVG output changes are not applicable.
2 parents 8c1dae0 + d6f9bd0 commit 4fda518

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
import { getIntensityColor } from './heatmapUtils';
4+
5+
describe('getIntensityColor', () => {
6+
it('returns the default gray class for intensity 0', () => {
7+
expect(getIntensityColor(0)).toBe('bg-gray-200 dark:bg-[#161616]');
8+
});
9+
10+
it('returns the correct class for intensity 1', () => {
11+
expect(getIntensityColor(1)).toBe('bg-gray-400 dark:bg-zinc-700');
12+
});
13+
14+
it('returns the correct class for intensity 2', () => {
15+
expect(getIntensityColor(2)).toBe('bg-gray-500 dark:bg-zinc-500');
16+
});
17+
18+
it('returns the correct class for intensity 3', () => {
19+
expect(getIntensityColor(3)).toBe('bg-gray-700 dark:bg-zinc-300');
20+
});
21+
22+
it('returns the correct class for intensity 4', () => {
23+
expect(getIntensityColor(4)).toBe('bg-black dark:bg-white');
24+
});
25+
26+
it('returns the default fallback class for intensity 99', () => {
27+
expect(getIntensityColor(99)).toBe('bg-gray-200 dark:bg-[#161616]');
28+
});
29+
30+
it('returns the default fallback class for intensity -1', () => {
31+
expect(getIntensityColor(-1)).toBe('bg-gray-200 dark:bg-[#161616]');
32+
});
33+
});

0 commit comments

Comments
 (0)