Skip to content

Commit 1e59cc5

Browse files
authored
test(time): verify getSecondsUntilUTCMidnight stays positive (JhaSourav07#776)
## Description Added a property-based style test to verify that `getSecondsUntilUTCMidnight()` always returns a positive value for every hour of the day. Fixes JhaSourav07#731 ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [x] 🕐 Pillar 3 — Timezone Logic Optimization - [ ] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A ## 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): ...`). - [ ] 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). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents d37d7de + 1cbd761 commit 1e59cc5

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

utils/time.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ describe('getSecondsUntilUTCMidnight', () => {
6565
});
6666
});
6767

68+
it('returns positive seconds for every hour of day', () => {
69+
for (let hour = 0; hour < 24; hour++) {
70+
const fakeDate = new Date(Date.UTC(2025, 0, 1, hour, 0, 0));
71+
72+
vi.setSystemTime(fakeDate);
73+
74+
const seconds = getSecondsUntilUTCMidnight();
75+
76+
expect(seconds).toBeGreaterThan(0);
77+
expect(seconds).toBeLessThanOrEqual(86400);
78+
}
79+
});
80+
6881
describe('getSecondsUntilMidnightInTimezone', () => {
6982
beforeEach(() => {
7083
vi.useFakeTimers();

0 commit comments

Comments
 (0)