Skip to content

Commit

Permalink
test(finance): use validator.js for bitcoin addresses (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
Minozzzi committed Sep 21, 2022
1 parent bdd380d commit ea8d873
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/modules/finance/index.ts
Expand Up @@ -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']);

Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/finance.spec.ts.snap
Expand Up @@ -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"`;

Expand Down Expand Up @@ -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"`;

Expand Down Expand Up @@ -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"`;

Expand Down
3 changes: 2 additions & 1 deletion 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';
Expand Down Expand Up @@ -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);
});
});

Expand Down

0 comments on commit ea8d873

Please sign in to comment.