test: add unit tests for dateRange.ts (#33) #36

Merged
maximus merged 1 commit from fix/simpl-resultat-33-daterange-tests into main 2026-03-11 11:12:25 +00:00
Collaborator

Summary

  • Install vitest as dev dependency and add test/test:watch npm scripts
  • Add 17 unit tests for src/utils/dateRange.ts covering:
    • computeDateRange: all period types (month, 3months, 6months, year, 12months, all, custom)
    • computeDateRange: January rollover edge cases for 3/6/12 months
    • computeDateRange: custom period with missing dates fallback
    • buildMonthOptions: correct length (24), ordering, January rollover, label capitalization

Fixes #33

Test plan

  • All 17 tests pass with npm test
  • Tests use fake timers to be fully deterministic

🤖 Generated with Claude Code

## Summary - Install vitest as dev dependency and add `test`/`test:watch` npm scripts - Add 17 unit tests for `src/utils/dateRange.ts` covering: - `computeDateRange`: all period types (month, 3months, 6months, year, 12months, all, custom) - `computeDateRange`: January rollover edge cases for 3/6/12 months - `computeDateRange`: custom period with missing dates fallback - `buildMonthOptions`: correct length (24), ordering, January rollover, label capitalization Fixes #33 ## Test plan - [x] All 17 tests pass with `npm test` - [x] Tests use fake timers to be fully deterministic 🤖 Generated with [Claude Code](https://claude.com/claude-code)
medic-bot added 1 commit 2026-03-11 03:05:46 +00:00
Add vitest and 17 tests covering computeDateRange (all periods
including January rollover) and buildMonthOptions (length, order,
rollover, label formatting). Add test/test:watch npm scripts.

Ref #33

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Collaborator

Reviewer automatique — approved

Les tests sont corrects, couvrent bien les deux fonctions exportées (computeDateRange et buildMonthOptions), incluent les cas de rollover de janvier, et les valeurs attendues correspondent exactement à l'implémentation du source. Le setup vitest dans package.json est propre.

Suggestions de simplification

  • src/utils/dateRange.test.ts : Le test 'falls back to default when custom has missing dates' (ligne 28) documente un comportement implicite de fallthrough du switch — le commentaire est bon, mais si ce comportement n'est pas intentionnel dans le code source, il faudrait plutôt corriger dateRange.ts que de le tester. À confirmer si c'est voulu.
## Reviewer automatique — approved Les tests sont corrects, couvrent bien les deux fonctions exportées (computeDateRange et buildMonthOptions), incluent les cas de rollover de janvier, et les valeurs attendues correspondent exactement à l'implémentation du source. Le setup vitest dans package.json est propre. ### Suggestions de simplification - **src/utils/dateRange.test.ts** : Le test 'falls back to default when custom has missing dates' (ligne 28) documente un comportement implicite de fallthrough du switch — le commentaire est bon, mais si ce comportement n'est pas intentionnel dans le code source, il faudrait plutôt corriger dateRange.ts que de le tester. À confirmer si c'est voulu.
maximus merged commit 501051f9ed into main 2026-03-11 11:12:25 +00:00
maximus deleted branch fix/simpl-resultat-33-daterange-tests 2026-03-11 11:12:26 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: maximus/Simpl-Resultat#36
No description provided.