diff options
| author | Marak <[email protected]> | 2021-02-11 10:42:28 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-11 10:42:28 -0500 |
| commit | b09ac6dee3625eeae9974761006fbdb1bd35f9ff (patch) | |
| tree | 7d9023fb8aa2464649d1daf6a1d0e67e4f318c86 /test | |
| parent | 08d43e82a2fa7d142695fa9102eb6ed1152e5791 (diff) | |
| parent | 642f0e55f11a413bf279bbf0c71df5fe2f3d74e2 (diff) | |
| download | faker-b09ac6dee3625eeae9974761006fbdb1bd35f9ff.tar.xz faker-b09ac6dee3625eeae9974761006fbdb1bd35f9ff.zip | |
Merge pull request #1015 from strobelt/autoFormatFlagOnFinanceAmount
Add autoFormat flag on finance amount
Diffstat (limited to 'test')
| -rw-r--r-- | test/finance.unit.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/finance.unit.js b/test/finance.unit.js index ae9db61c..ea474f59 100644 --- a/test/finance.unit.js +++ b/test/finance.unit.js @@ -223,6 +223,26 @@ describe('finance.js', function () { assert.strictEqual(typeOfAmount , "string", "the amount type should be number"); }); + [false, undefined].forEach(function (autoFormat){ + it(`should return unformatted if autoformat is ${autoFormat}`, function() { + + const number = 6000; + const amount = faker.finance.amount(number, number, 0, undefined, autoFormat); + + assert.strictEqual(amount, number.toString()); + }); + }); + + it("should return the number formatted on the current locale", function() { + + const number = 6000, decimalPlaces = 2; + const expected = number.toLocaleString(undefined, {minimumFractionDigits: decimalPlaces}); + + const amount = faker.finance.amount(number, number, decimalPlaces, undefined, true); + + assert.strictEqual(amount, expected); + }); + }); describe('transactionType()', function () { |
