Skip to content

Commit

Permalink
Add additional test for Money.new/3 with locale
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed Oct 16, 2018
1 parent cf7f25b commit 821c550
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/money_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ defmodule MoneyTest do
assert money.amount == Decimal.new(1234)
end

test "create a new currency with a locale to normalise an amount string" do
money = Money.new(:USD, "1.234.567,99", locale: "de")
assert money.currency == :USD
assert money.amount == Decimal.new("1234567.99")

money = Money.new(:USD, "1,234,567.99", locale: "en")
assert money.currency == :USD
assert money.amount == Decimal.new("1234567.99")
end

test "create a new money struct from a tuple" do
money = Money.from_tuple({"USD", 1234})
assert money.currency == :USD
Expand Down

0 comments on commit 821c550

Please sign in to comment.