aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoosh <[email protected]>2021-02-24 06:54:34 +0100
committerMoosh <[email protected]>2021-02-24 06:54:34 +0100
commit03f735dbc1b2a693f8b73233c49addd4d1362d12 (patch)
treec20a3f7ebb3b47d5f4ea815876202414c8848a61
parent85c8c0dc9d7bd703ed689c88493139560c5dcd5f (diff)
downloadfaker-03f735dbc1b2a693f8b73233c49addd4d1362d12.tar.xz
faker-03f735dbc1b2a693f8b73233c49addd4d1362d12.zip
add tdd for #846
-rw-r--r--test/finance_issue.unit.js33
1 files changed, 32 insertions, 1 deletions
diff --git a/test/finance_issue.unit.js b/test/finance_issue.unit.js
index 646d8adc..7c59d780 100644
--- a/test/finance_issue.unit.js
+++ b/test/finance_issue.unit.js
@@ -133,4 +133,35 @@ describe('finance_issue.js', function () {
assert.equal(ibanLib.mod97(ibanLib.toDigitString(bban)), 1, "the result should be equal to 1");
});
});
-});
+
+ describe("issue_846 IBAN Azerbaijan", function () {
+ // Azerbaijan
+ // https://transferwise.com/fr/iban/azerbaijan
+ // Length 21
+ // BBAN 2c,16n
+ // GEkk bbbb cccc cccc cccc cccc cccc
+ // b = National bank code (alpha)
+ // c = Account number
+
+ // example IBAN AZ21 NABZ 0000 0000 1370 1000 1944
+
+ var ibanLib = require('../lib/iban');
+
+ it("IBAN for Azerbaijan is correct", function () {
+
+ faker.seed(17);
+ var iban = getAnIbanByCountry('AZ');
+ var ibanFormated = iban.match(/.{1,4}/g).join(" ");
+ var bban = iban.substring(4) + iban.substring(0, 4);
+
+ assert.equal(28, iban.length, 'AZ IBAN would be 28 chars length, given is ' + iban.length);
+
+ assert.ok(iban.substring(0, 2).match(/^[A-Z]{2}$/), iban.substring(0, 2) + ' must contains only characters in AZ IBAN ' + ibanFormated);
+ assert.ok(iban.substring(2, 4).match(/^\d{2}$/), iban.substring(2, 4) + ' must contains only digit in AZ IBAN ' + ibanFormated);
+ assert.ok(iban.substring(4, 8).match(/^[A-Z]{4}$/), iban.substring(4, 8) + ' must contains only characters in AZ IBAN ' + ibanFormated);
+ assert.ok(iban.substring(8, 24).match(/^\d{20}$/), iban.substring(8, 24) + ' must contains only characters in AZ IBAN ' + ibanFormated);
+
+ assert.equal(ibanLib.mod97(ibanLib.toDigitString(bban)), 1, "the result should be equal to 1");
+ });
+ });
+ });