From 434b3174b1cd3cf568c06aefbc2e8d000b397adf Mon Sep 17 00:00:00 2001 From: alexpts Date: Sat, 11 Feb 2017 09:24:12 +0300 Subject: Fix aomount and price argument dec for case = 0. Add unit tests. Minor codestyle fix. --- test/commerce.unit.js | 17 +++++++++++++++++ test/finance.unit.js | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/commerce.unit.js b/test/commerce.unit.js index 06445e34..12b06887 100644 --- a/test/commerce.unit.js +++ b/test/commerce.unit.js @@ -110,6 +110,23 @@ describe("commerce.js", function() { assert.ok(amount); assert.equal((amount == 0.00), true, "the amount should equal 0"); }); + + it("it should handle argument dec", function () { + + var price = faker.commerce.price(100, 100, 1); + + assert.ok(price); + assert.strictEqual(price , '100.0', "the price should be equal 100.0"); + }); + + it("it should handle argument dec = 0", function () { + + var price = faker.commerce.price(100, 100, 0); + + assert.ok(price); + assert.strictEqual(price , '100', "the price should be equal 100"); + }); + }); }); \ No newline at end of file diff --git a/test/finance.unit.js b/test/finance.unit.js index 6bbb51c6..22461f22 100644 --- a/test/finance.unit.js +++ b/test/finance.unit.js @@ -184,6 +184,22 @@ describe('finance.js', function () { }); + it("it should handle argument dec", function () { + + var amount = faker.finance.amount(100, 100, 1); + + assert.ok(amount); + assert.strictEqual(amount , '100.0', "the amount should be equal 100.0"); + }); + + it("it should handle argument dec = 0", function () { + + var amount = faker.finance.amount(100, 100, 0); + + assert.ok(amount); + assert.strictEqual(amount , '100', "the amount should be equal 100"); + }); + }); describe('transactionType()', function () { @@ -201,7 +217,7 @@ describe('finance.js', function () { assert.ok(currencyCode.match(/[A-Z]{3}/)); }); - }) + }); describe("bitcoinAddress()", function(){ it("returns a random bitcoin address", function(){ -- cgit v1.2.3