Commit b1b0b6c
authored
leap streak (JhaSourav07#2021)
## Description
This pull request introduces a highly specific unit test suite in
`lib/calculate.test.ts` to validate timezone boundaries and calendar
offsets during the February 28 to March 1 transition.
By comparing leap years (e.g., 2020) and non-leap years (e.g., 2021)
with both active and inactive leap days, the new test ensures that
streak calculations are resilient against off-by-one errors and gap
boundary misalignments.
### Scenarios Covered in the Test:
1. **Non-Leap Year (2021)**: Verifies that a user committing on Feb 28
and Mar 1 achieves a continuous **2-day** streak since Feb 29 does not
exist.
2. **Leap Year (2020) with a Missed Leap Day**: Verifies that when Feb
29 has 0 commits, the streak correctly breaks, resulting in a current
and longest streak of **1 day** on Mar 1.
3. **Leap Year (2020) with an Active Leap Day**: Verifies that
committing on Feb 28, Feb 29, and Mar 1 results in a seamless **3-day**
streak.
fixes JhaSourav07#1501
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [ ] 📐 Pillar 2 — Geometric SVG Improvement
- [x] 🕐 Pillar 3 — Timezone Logic Optimization
- [x] 🛠️ Other (Unit testing)
## Visual Preview
*(N/A - This is a pure logic & unit testing addition)*
## 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): ...`).
- [x] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have starred the repo.
- [x] I have made sure that I have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
- [x] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.1 file changed
Lines changed: 64 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
504 | 568 | | |
505 | 569 | | |
506 | 570 | | |
| |||
0 commit comments