2017-11-29 05:31:03 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const expect = require("chai").expect;
|
2019-11-21 09:11:06 +00:00
|
|
|
const roundBadgeNumber = require("../../../../client/js/helpers/roundBadgeNumber").default;
|
2017-11-29 05:31:03 +00:00
|
|
|
|
2019-11-05 10:36:44 +00:00
|
|
|
describe("roundBadgeNumber helper", function() {
|
2017-11-29 05:31:03 +00:00
|
|
|
it("should return any number under 1000 as a string", function() {
|
|
|
|
expect(roundBadgeNumber(123)).to.equal("123");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return numbers above 999 in thousands", function() {
|
|
|
|
expect(roundBadgeNumber(1000)).to.be.equal("1.0k");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should round and not floor", function() {
|
|
|
|
expect(roundBadgeNumber(9999)).to.be.equal("10.0k");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should always include a single digit when rounding up", function() {
|
|
|
|
expect(roundBadgeNumber(1234)).to.be.equal("1.2k");
|
|
|
|
expect(roundBadgeNumber(12345)).to.be.equal("12.3k");
|
|
|
|
expect(roundBadgeNumber(123456)).to.be.equal("123.4k");
|
|
|
|
});
|
|
|
|
});
|