Skip to content

test(Common): add tests for Types/RollingTime/RollingTimeUtil#2585

Open
suvvvv wants to merge 1 commit into
OneUptime:masterfrom
suvvvv:test/rolling-time-util
Open

test(Common): add tests for Types/RollingTime/RollingTimeUtil#2585
suvvvv wants to merge 1 commit into
OneUptime:masterfrom
suvvvv:test/rolling-time-util

Conversation

@suvvvv

@suvvvv suvvvv commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Adds unit tests for RollingTimeUtil in Common/Types/RollingTime/RollingTimeUtil.ts, which previously had no test coverage. This util maps a rolling-time option (e.g. "Past 7 Days") to a start/end InBetween<Date> range ending now.

Covered:

  • getDefault — returns Past1Minute.
  • convertToStartAndEndDate — every RollingTime value produces a window that ends at (approximately) now and starts the expected amount earlier. Each expected start is recomputed with the same OneUptimeDate helper the util uses, off the util's own end date, so the assertion is DST-safe rather than comparing against a hardcoded millisecond count. Also covers the Past1Hours quirk (labelled "Past 1 Day", subtracts a day), that the result is an InBetween instance, and that longer windows produce earlier start dates.

Time-dependent assertions use a small tolerance to absorb the gap between the util's two getCurrentDate() calls.

Why

Improves test coverage for the Common/Types utilities (part of the broader test-coverage effort).

Testing

node node_modules/.bin/jest --runInBand ./Tests/Types/RollingTime/RollingTimeUtil.test.ts

All 23 tests pass. The file is Prettier-clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@simlarsen

Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants