fmt: shared number formatting for HTML and PDF
All checks were successful
Build and Deploy to Production / test (push) Successful in 2m28s
Build and Deploy to Production / build (push) Successful in 52s
Build and Deploy to Production / deploy (push) Successful in 30s

This commit is contained in:
Sergei Poljanski 2026-07-02 18:40:20 +04:00
commit f7319a08a9
Signed by: asxpi
GPG key ID: 4F8851660FA4121B
4 changed files with 54 additions and 18 deletions

22
test/fmt_test.rb Normal file
View file

@ -0,0 +1,22 @@
require_relative 'test_helper'
class FmtTest < Minitest::Test
def test_rate_pads_to_min_dp
assert_equal '2.9500', Fmt.rate('2.95')
assert_equal '3.0000', Fmt.rate(3)
end
def test_rate_keeps_captured_precision
assert_equal '2.95123456', Fmt.rate('2.95123456')
end
def test_rate_groups_thousands
assert_equal '1,050.2500', Fmt.rate('1050.25')
end
def test_ltc_trims_trailing_zeros
assert_equal '1.25', Fmt.ltc('1.250000')
assert_equal '2', Fmt.ltc('2.0')
assert_equal '0.00123456', Fmt.ltc('0.00123456')
end
end