aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Minozzi <[email protected]>2022-09-21 09:56:47 -0300
committerGitHub <[email protected]>2022-09-21 14:56:47 +0200
commitea8d873c5388f405fbdd18ad4ff978bc49996868 (patch)
treea2342993741f0259df60646becb6fcedfe95e178
parentbdd380db2c96abef3f46a12b446b5b0b5725b40c (diff)
downloadfaker-ea8d873c5388f405fbdd18ad4ff978bc49996868.tar.xz
faker-ea8d873c5388f405fbdd18ad4ff978bc49996868.zip
test(finance): use validator.js for bitcoin addresses (#1375)
-rw-r--r--src/modules/finance/index.ts2
-rw-r--r--test/__snapshots__/finance.spec.ts.snap6
-rw-r--r--test/finance.spec.ts3
3 files changed, 6 insertions, 5 deletions
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts
index d1580603..c73bf6ae 100644
--- a/src/modules/finance/index.ts
+++ b/src/modules/finance/index.ts
@@ -231,7 +231,7 @@ export class FinanceModule {
* @since 3.1.0
*/
bitcoinAddress(): string {
- const addressLength = this.faker.datatype.number({ min: 25, max: 34 });
+ const addressLength = this.faker.datatype.number({ min: 25, max: 39 });
let address = this.faker.helpers.arrayElement(['1', '3']);
diff --git a/test/__snapshots__/finance.spec.ts.snap b/test/__snapshots__/finance.spec.ts.snap
index 1cc36e29..e42b6c80 100644
--- a/test/__snapshots__/finance.spec.ts.snap
+++ b/test/__snapshots__/finance.spec.ts.snap
@@ -18,7 +18,7 @@ exports[`finance > 42 > amount > with min and max and dec and symbol 1`] = `"$24
exports[`finance > 42 > bic 1`] = `"JUYEPSSLXXX"`;
-exports[`finance > 42 > bitcoinAddress 1`] = `"3XbJMAAara64sSkA9HD24YHQWd1b"`;
+exports[`finance > 42 > bitcoinAddress 1`] = `"3XbJMAAara64sSkA9HD24YHQWd1bZb"`;
exports[`finance > 42 > creditCardCVV 1`] = `"379"`;
@@ -82,7 +82,7 @@ exports[`finance > 1211 > amount > with min and max and dec and symbol 1`] = `"$
exports[`finance > 1211 > bic 1`] = `"YLXUDE4Z"`;
-exports[`finance > 1211 > bitcoinAddress 1`] = `"1TMe8Z3EaFdLqmaGKP1LEEJQVriSZRZdsA"`;
+exports[`finance > 1211 > bitcoinAddress 1`] = `"1TMe8Z3EaFdLqmaGKP1LEEJQVriSZRZdsAUc9n"`;
exports[`finance > 1211 > creditCardCVV 1`] = `"948"`;
@@ -146,7 +146,7 @@ exports[`finance > 1337 > amount > with min and max and dec and symbol 1`] = `"$
exports[`finance > 1337 > bic 1`] = `"GOEFFIJG"`;
-exports[`finance > 1337 > bitcoinAddress 1`] = `"3adhxs2jewAgkYgJi7No6Cn8JZa"`;
+exports[`finance > 1337 > bitcoinAddress 1`] = `"3adhxs2jewAgkYgJi7No6Cn8JZar"`;
exports[`finance > 1337 > creditCardCVV 1`] = `"251"`;
diff --git a/test/finance.spec.ts b/test/finance.spec.ts
index afc671a7..70534449 100644
--- a/test/finance.spec.ts
+++ b/test/finance.spec.ts
@@ -1,3 +1,4 @@
+import isValidBtcAddress from 'validator/lib/isBtcAddress';
import { afterEach, describe, expect, it } from 'vitest';
import { faker } from '../src';
import { FakerError } from '../src/errors/faker-error';
@@ -290,7 +291,7 @@ describe('finance', () => {
expect(bitcoinAddress).toBeTruthy();
expect(bitcoinAddress).toBeTypeOf('string');
- expect(bitcoinAddress).toMatch(/^[13][a-km-zA-HJ-NP-Z1-9]{24,33}$/);
+ expect(bitcoinAddress).toSatisfy(isValidBtcAddress);
});
});