Skip to content

test(rank): cover the three previously-untested rank tiers (A-, B, C+)#4869

Open
MukundaKatta wants to merge 1 commit into
anuraghazra:masterfrom
MukundaKatta:test/cover-missing-rank-tiers
Open

test(rank): cover the three previously-untested rank tiers (A-, B, C+)#4869
MukundaKatta wants to merge 1 commit into
anuraghazra:masterfrom
MukundaKatta:test/cover-missing-rank-tiers

Conversation

@MukundaKatta

Copy link
Copy Markdown

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 }`):

Added test Target level Band Percentile
`rising user gets A- rank` A- 25–37.5 31.85
`casual user gets B rank` B 50–62.5 56.93
`occasional user gets C+ rank` C+ 75–87.5 83.37

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

  • No source changes.
  • Single file: `tests/calculateRank.test.js`.
  • Conventional commit type `test:` per repo convention.

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.
@vercel

vercel Bot commented Apr 22, 2026

Copy link
Copy Markdown

@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.

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.

1 participant