File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ module Formatting
1818 # @parameter units [Array] The units to use for formatting (default: UNITS).
1919 # @returns [String] A formatted string representing the count.
2020 def format_count ( value , units = UNITS )
21- value = value . to_f
21+ value = value
2222 index = 0
2323 limit = units . size - 1
2424
@@ -27,7 +27,7 @@ def format_count(value, units = UNITS)
2727 value = value . abs
2828
2929 while value >= 1000 and index < limit
30- value = value / 1000
30+ value = value / 1000.0
3131 index += 1
3232 end
3333
Original file line number Diff line number Diff line change 88describe Async ::Service ::Formatting do
99 with "#format_count" do
1010 it "formats small numbers without units" do
11- expect ( subject . format_count ( 0 ) ) . to be == "0.0"
12- expect ( subject . format_count ( 1 ) ) . to be == "1.0"
13- expect ( subject . format_count ( 999 ) ) . to be == "999.0"
11+ expect ( subject . format_count ( 0 ) ) . to be == "0"
12+ expect ( subject . format_count ( 0.0 ) ) . to be == "0.0"
13+
14+ expect ( subject . format_count ( 1 ) ) . to be == "1"
15+ expect ( subject . format_count ( 1.0 ) ) . to be == "1.0"
16+
17+ expect ( subject . format_count ( 999 ) ) . to be == "999"
1418 end
1519
1620 it "formats thousands with K unit" do
You can’t perform that action at this time.
0 commit comments