aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuiz Strobelt <[email protected]>2020-10-01 22:17:02 -0300
committerLuiz Strobelt <[email protected]>2020-10-01 22:17:02 -0300
commitd9ed407cab9dd1031e20caa9ebec2612ddbd8f8e (patch)
tree1124fa0ba24e40338880d4e03585b1e6cd3fb51f /test
parentd6ee1c544f33722852b024994d150cd4703b0972 (diff)
downloadfaker-d9ed407cab9dd1031e20caa9ebec2612ddbd8f8e.tar.xz
faker-d9ed407cab9dd1031e20caa9ebec2612ddbd8f8e.zip
Test passing false or undefined to autoFormat
Diffstat (limited to 'test')
-rw-r--r--test/finance.unit.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/finance.unit.js b/test/finance.unit.js
index 79ac26db..4c0b09c9 100644
--- a/test/finance.unit.js
+++ b/test/finance.unit.js
@@ -150,7 +150,7 @@ describe('finance.js', function () {
});
- describe.only('amount(min, max, dec, symbol)', function () {
+ describe('amount(min, max, dec, symbol)', function () {
it("should use the default amounts when not passing arguments", function () {
var amount = faker.finance.amount();
@@ -223,16 +223,22 @@ describe('finance.js', function () {
assert.strictEqual(typeOfAmount , "string", "the amount type should be number");
});
- it("should return unformatted if autoformat i false", function() {
+ [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 with a comma separator", function() {
+ it("should return the number formatted on the current locale", function() {
- const symbol = "$", number = 6000, decimalPlaces = 2;
- const expected = symbol + number.toLocaleString(undefined, {minimumFractionDigits: decimalPlaces});
+ const number = 6000, decimalPlaces = 2;
+ const expected = number.toLocaleString(undefined, {minimumFractionDigits: decimalPlaces});
- const amount = faker.finance.amount(number, number, decimalPlaces, symbol, true);
+ const amount = faker.finance.amount(number, number, decimalPlaces, undefined, true);
assert.strictEqual(amount, expected);
});