New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use "M" shorthand for messages >= one million #4659
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,15 @@ describe("roundBadgeNumber helper", function () { | |
expect(roundBadgeNumber(123)).to.equal("123"); | ||
}); | ||
|
||
it("should return numbers above 999 in thousands", function () { | ||
it("should return numbers between 1000 and 999999 with a 'k' suffix", function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a few more expects, e.g. 999999 is in fact 999k |
||
expect(roundBadgeNumber(1000)).to.be.equal("1.0k"); | ||
}); | ||
|
||
it("should return numbers above 999999 with a 'M' suffix", function () { | ||
expect(roundBadgeNumber(1000000)).to.be.equal("1.0M"); | ||
expect(roundBadgeNumber(1234567)).to.be.equal("1.2M"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test for much higher magnitude number (with current code it would validate that it |
||
}); | ||
|
||
it("should round and not floor", function () { | ||
expect(roundBadgeNumber(9999)).to.be.equal("10.0k"); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I understand the use case here, I think it's simpler to just have two if cases to handle
M/k
.