diff options
| author | CoDEmanX <[email protected]> | 2016-04-07 11:31:33 +0200 |
|---|---|---|
| committer | CoDEmanX <[email protected]> | 2016-04-07 14:14:46 +0200 |
| commit | 94b65cbf334ea5ef1c4838711bc0945125f7c779 (patch) | |
| tree | 020ce2b1eec3e949ce8658ebe85bf83255453ae8 /test | |
| parent | 38e890eeced869b41cf0047ef28740bfb79d1c01 (diff) | |
| download | faker-94b65cbf334ea5ef1c4838711bc0945125f7c779.tar.xz faker-94b65cbf334ea5ef1c4838711bc0945125f7c779.zip | |
Add IBAN and BIC generator functions
Diffstat (limited to 'test')
| -rw-r--r-- | test/finance.unit.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/test/finance.unit.js b/test/finance.unit.js index 8be7d2c8..ee4bfbd6 100644 --- a/test/finance.unit.js +++ b/test/finance.unit.js @@ -201,7 +201,7 @@ describe('finance.js', function () { assert.ok(currencyCode.match(/[A-Z]{3}/)); }); - }) + }); describe("bitcoinAddress()", function(){ it("returns a random bitcoin address", function(){ @@ -210,4 +210,24 @@ describe('finance.js', function () { assert.ok(bitcoinAddress.match(/^[A-Z0-9.]{27,34}$/)); }); }); + + describe("iban()", function () { + var ibanLib = require('../lib/iban'); + it("returns a random yet formally correct IBAN number", function () { + var iban = faker.finance.iban(); + var bban = iban.substring(4) + iban.substring(0, 4); + + assert.equal(ibanLib.mod97(ibanLib.toDigitString(bban)), 1, "the result should be equal to 1"); + }); + }); + + describe("bic()", function () { + var ibanLib = require('../lib/iban'); + it("returns a random yet formally correct BIC number", function () { + var bic = faker.finance.bic(); + var expr = new RegExp("^[A-Z]{4}(" + ibanLib.iso3166.join("|") + ")[A-Z2-9][A-NP-Z0-9]([A-Z0-9]{3})?$", "i"); + + assert.ok(bic.match(expr)); + }); + }); });
\ No newline at end of file |
