diff options
Diffstat (limited to 'packages/taler-util/src/amounts.test.ts')
-rw-r--r-- | packages/taler-util/src/amounts.test.ts | 72 |
1 files changed, 56 insertions, 16 deletions
diff --git a/packages/taler-util/src/amounts.test.ts b/packages/taler-util/src/amounts.test.ts index e592d965c..449a6319a 100644 --- a/packages/taler-util/src/amounts.test.ts +++ b/packages/taler-util/src/amounts.test.ts @@ -121,31 +121,71 @@ test("amount parsing", (t) => { }); test("amount stringification", (t) => { - t.is(Amounts.stringify(jAmt(0, 0, "TESTKUDOS")), "TESTKUDOS:0" as AmountString); - t.is(Amounts.stringify(jAmt(4, 94000000, "TESTKUDOS")), "TESTKUDOS:4.94" as AmountString); - t.is(Amounts.stringify(jAmt(0, 10000000, "TESTKUDOS")), "TESTKUDOS:0.1" as AmountString); - t.is(Amounts.stringify(jAmt(0, 1, "TESTKUDOS")), "TESTKUDOS:0.00000001" as AmountString); - t.is(Amounts.stringify(jAmt(5, 0, "TESTKUDOS")), "TESTKUDOS:5" as AmountString); + t.is( + Amounts.stringify(jAmt(0, 0, "TESTKUDOS")), + "TESTKUDOS:0" as AmountString, + ); + t.is( + Amounts.stringify(jAmt(4, 94000000, "TESTKUDOS")), + "TESTKUDOS:4.94" as AmountString, + ); + t.is( + Amounts.stringify(jAmt(0, 10000000, "TESTKUDOS")), + "TESTKUDOS:0.1" as AmountString, + ); + t.is( + Amounts.stringify(jAmt(0, 1, "TESTKUDOS")), + "TESTKUDOS:0.00000001" as AmountString, + ); + t.is( + Amounts.stringify(jAmt(5, 0, "TESTKUDOS")), + "TESTKUDOS:5" as AmountString, + ); // denormalized - t.is(Amounts.stringify(jAmt(1, 100000000, "TESTKUDOS")), "TESTKUDOS:2" as AmountString); + t.is( + Amounts.stringify(jAmt(1, 100000000, "TESTKUDOS")), + "TESTKUDOS:2" as AmountString, + ); t.pass(); }); test("amount multiplication", (t) => { - t.is(Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 0).amount), "EUR:0" as AmountString); - t.is(Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 1).amount), "EUR:1.11" as AmountString); - t.is(Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 2).amount), "EUR:2.22" as AmountString); - t.is(Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 3).amount), "EUR:3.33" as AmountString); - t.is(Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 4).amount), "EUR:4.44" as AmountString); - t.is(Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 5).amount), "EUR:5.55" as AmountString); + t.is( + Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 0).amount), + "EUR:0" as AmountString, + ); + t.is( + Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 1).amount), + "EUR:1.11" as AmountString, + ); + t.is( + Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 2).amount), + "EUR:2.22" as AmountString, + ); + t.is( + Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 3).amount), + "EUR:3.33" as AmountString, + ); + t.is( + Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 4).amount), + "EUR:4.44" as AmountString, + ); + t.is( + Amounts.stringify(Amounts.mult(sAmt("EUR:1.11"), 5).amount), + "EUR:5.55" as AmountString, + ); }); - - test("amount division", (t) => { t.is(Amounts.divmod("EUR:5", "EUR:1").quotient, 5); - t.is(Amounts.stringify(Amounts.divmod("EUR:5", "EUR:1").remainder), "EUR:0" as AmountString); + t.is( + Amounts.stringify(Amounts.divmod("EUR:5", "EUR:1").remainder), + "EUR:0" as AmountString, + ); t.is(Amounts.divmod("EUR:5", "EUR:2").quotient, 2); - t.is(Amounts.stringify(Amounts.divmod("EUR:5", "EUR:2").remainder), "EUR:1" as AmountString); + t.is( + Amounts.stringify(Amounts.divmod("EUR:5", "EUR:2").remainder), + "EUR:1" as AmountString, + ); }); |