test : added unit tests for StreakTracker component#792
Conversation
|
@TESTPERSONAL is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
Tests must import from source — not reimplement the function locally.
The test file re-implements the function being tested inside the test itself. This defeats the purpose of testing — changes to the real implementation won't fail these tests.
Fix: import the actual function from its source file and test that import. Example:
import { safeCompare } from '../src/lib/crypto'
// then test safeCompare directlyAlso fix:
- Add
"test": "vitest run"toscriptsinpackage.json - Add
vitest.config.tswithresolve.alias: { '@': path.resolve(__dirname, 'src') } - Add EOF newline to test file
eb90a40 to
e8c79db
Compare
Closes Priyanshu-byte-coder#772 Added test/StreakTracker.test.ts covering: - STREAK_MILESTONES: expected values, ascending order - StreakData interface: zero streak, active streak with freezes - Clipboard API: writeText behavior, unavailable clipboard handling - Freeze badge: shown/hidden based on freezeDates array - Milestone banner: shows at 7/30/50/100/200/365 days, first milestone logic, null when not reached - useCountUp integration: correct target values, zero handling - Loading/data/error states: null data with loading, complete data, error object - ContributionData: structure with days/total/data, empty case Impact: All 24 tests pass. Streak data handling and milestone detection validated.
…test for type checking
Closes #772.
Summary of What Has Been Done:
Added test/StreakTracker.test.ts with 24 vitest tests covering the StreakTracker component's data structures and UI logic.
Changes Made:
New file: test/StreakTracker.test.ts
Test coverage:
Impact it Made:
All 24 tests pass. Streak display logic validated across all data states (loading, success, error, zero).