test: add missing month parsing and zero value coverage#287
Open
mahmoodhamdi wants to merge 1 commit intovercel:mainfrom
Open
test: add missing month parsing and zero value coverage#287mahmoodhamdi wants to merge 1 commit intovercel:mainfrom
mahmoodhamdi wants to merge 1 commit intovercel:mainfrom
Conversation
The ms(string) and ms(long string) test sections cover every unit
(y, w, d, h, m, s, ms) except months — even though months are
supported since v3 and tested in parse.test.ts. This adds the
missing cases through the main ms() entry point.
Also adds zero-value tests (ms('0'), ms('0ms'), ms(0), ms(0, {long}))
which were previously untested.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While working with ms for cache TTL logic, I noticed the test suite has a gap: the
ms(string)andms(long string)sections test every supported unit except months. Themo/month/monthsunit is tested inparse.test.tsandparse-strict.test.ts, but not through the mainms()entry point.Also, zero-value behavior was completely untested.
Tests Added
Month parsing via
ms():ms('1mo')→2629800000ms('1 month')→2629800000Zero values:
ms('0')→0ms('0ms')/ms('0s')/ms('0h')→0ms(0)→'0ms'ms(0, { long: true })→'0 ms'Checks
pnpm test— 173 tests pass (Node.js + Edge Runtime)pnpm typecheck— cleanpnpm lint— cleanNo code changes — tests only.