test(rank): cover the three previously-untested rank tiers (A-, B, C+)#4869
Open
MukundaKatta wants to merge 1 commit into
Open
test(rank): cover the three previously-untested rank tiers (A-, B, C+)#4869MukundaKatta wants to merge 1 commit into
MukundaKatta wants to merge 1 commit into
Conversation
calculateRank yields nine levels — S, A+, A, A-, B+, B, B-, C+, C — but calculateRank.test.js previously exercised only six (S, A+, A, B+, B-, C). A-, B, and C+ had no test at all, so rank-boundary regressions in those bands wouldn't be caught. Add three cases that land squarely inside each missing band: - "rising user gets A- rank" → percentile 31.85 (band 25–37.5) - "casual user gets B rank" → percentile 56.93 (band 50–62.5) - "occasional user gets C+ rank" → percentile 83.37 (band 75–87.5) Inputs were chosen so each percentile is comfortably inside its band (>1 percentile point from either boundary), so minor floating-point drift across Node versions shouldn't flip the level. Style matches the existing toStrictEqual assertions in the file. No source / prod changes.
|
@MukundaKatta is attempting to deploy a commit to the github readme stats Team on Vercel. A member of the Team first needs to authorize it. |
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
`calculateRank` returns one of nine levels — S, A+, A, A-, B+, B, B-, C+, C — but `tests/calculateRank.test.js` previously exercised only six (S, A+, A, B+, B-, C). A-, B, and C+ had no test at all, so any boundary regression in those bands would have gone unnoticed.
This PR adds three cases, one per missing band, matching the style of the existing tests (`toStrictEqual` on `{ level, percentile }`):
Inputs were picked so each percentile lands comfortably inside its band (≥1 percentile point from either threshold), to minimise flakiness from Node-version floating-point drift.
Verification
```
$ node --experimental-vm-modules node_modules/jest/bin/jest.js \
tests/calculateRank.test.js \
--testNamePattern 'A- rank|B rank|C\+ rank'
Tests: 3 passed, 10 total
```
Prettier clean: `prettier --check tests/calculateRank.test.js` passes.
Heads-up (not addressed here)
While preparing this PR I noticed the pre-existing `beginner user gets B- rank` test is fragile across Node versions — on Node 25 it produces percentile `65.02918514848257` where the test expects `65.02918514848255` (2 ULPs drift). Happy to file that separately if you want a follow-up PR using `toBeCloseTo`; deliberately left out of this PR to keep scope tight.
Scope