aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Gesché <[email protected]>2021-02-23 12:38:39 +0100
committerChristophe Gesché <[email protected]>2021-02-23 12:38:39 +0100
commit85c8c0dc9d7bd703ed689c88493139560c5dcd5f (patch)
treee1fd32f1e48d5023fba80e21ada1105d03ec190b
parentbb3e08c2d23b9a63cb56fbe06eb4972650726243 (diff)
downloadfaker-85c8c0dc9d7bd703ed689c88493139560c5dcd5f.tar.xz
faker-85c8c0dc9d7bd703ed689c88493139560c5dcd5f.zip
optimize test
- Seed to found Iban at first loop - Console log display the tips if the fonction is called for a new locale
-rw-r--r--test/finance_issue.unit.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/finance_issue.unit.js b/test/finance_issue.unit.js
index 5b35d725..646d8adc 100644
--- a/test/finance_issue.unit.js
+++ b/test/finance_issue.unit.js
@@ -6,17 +6,19 @@ if (typeof module !== 'undefined') {
function getAnIbanByCountry(countryCode) {
var iban = faker.finance.iban();
var maxTry = 100000;
- faker.seed();
- while (maxTry && iban.substring(0, 2) != countryCode) {
- faker.seed();
+ var countTry = maxTry;
+ while (countTry && iban.substring(0, 2) != countryCode) {
+ faker.seed(100000- countTry);
iban = faker.finance.iban();
- maxTry--;
+ countTry--;
}
- if (maxTry === 0) {
+ if (countTry === 0) {
console.log('Not found with 10000 seed, vraiment pas de bol');
+ } else if (countTry < maxTry) {
+ console.log('you can optimize this helper by add faker.seed(' + (100000 - 1 - countTry) + ') before the call of getAnIbanByCountry()');
}
- console.log(iban);
+ // console.log(iban);
return iban;
}
@@ -38,6 +40,7 @@ describe('finance_issue.js', function () {
it("IBAN for Georgia is correct", function () {
+ faker.seed(17);
var iban = getAnIbanByCountry('GE');
var ibanFormated = iban.match(/.{1,4}/g).join(" ");
var bban = iban.substring(4) + iban.substring(0, 4);
@@ -71,6 +74,7 @@ describe('finance_issue.js', function () {
it("IBAN for Pakistan is correct", function () {
+ faker.seed(28);
var iban = getAnIbanByCountry('PK');
var ibanFormated = iban.match(/.{1,4}/g).join(" ");
var bban = iban.substring(4) + iban.substring(0, 4);
@@ -88,7 +92,6 @@ describe('finance_issue.js', function () {
describe("issue_946 IBAN Turkish", function () {
-
// https://transferwise.com/fr/iban/turkey
// Un IBAN en Turquie est constitué de 26 caractères :
//
@@ -111,6 +114,8 @@ describe('finance_issue.js', function () {
it("IBAN for Turkish is correct", function () {
+ faker.seed(37);
+
var iban = getAnIbanByCountry('TR');
var ibanFormated = iban.match(/.{1,4}/g).join(" ");
var bban = iban.substring(4) + iban.substring(0, 4);