aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-04-03 17:47:19 +0200
committerGitHub <[email protected]>2023-04-03 15:47:19 +0000
commitde078de89bf1b52de153f88352cf534811673886 (patch)
treeb31ed78c845eed81202073cd2e8656d75ac37140
parentedc50b69197260f9d3e8ac22f2bf062c9a71c390 (diff)
downloadfaker-de078de89bf1b52de153f88352cf534811673886.tar.xz
faker-de078de89bf1b52de153f88352cf534811673886.zip
refactor(finance)!: simplify account implementation (#1992)
-rw-r--r--src/modules/finance/index.ts14
-rw-r--r--test/finance.spec.ts10
2 files changed, 2 insertions, 22 deletions
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts
index 56b298eb..579bd89b 100644
--- a/src/modules/finance/index.ts
+++ b/src/modules/finance/index.ts
@@ -135,19 +135,9 @@ export class FinanceModule {
options = { length: options };
}
- let { length = 8 } = options;
- if (length === 0) {
- length = 8;
- }
-
- let template = '';
+ const { length = 8 } = options;
- for (let i = 0; i < length; i++) {
- template += '#';
- }
-
- length = null;
- return this.faker.helpers.replaceSymbolWithNumber(template);
+ return this.faker.string.numeric({ length, allowLeadingZeros: true });
}
/**
diff --git a/test/finance.spec.ts b/test/finance.spec.ts
index c71b3d38..864ddb3b 100644
--- a/test/finance.spec.ts
+++ b/test/finance.spec.ts
@@ -123,16 +123,6 @@ describe('finance', () => {
).toHaveLength(8);
});
- it('should supply a default length if a zero is passed', () => {
- const accountNum = faker.finance.account(0);
-
- expect(accountNum).toBeTruthy();
- expect(
- accountNum,
- 'The length of the account number should be 8 characters long'
- ).toHaveLength(8);
- });
-
it('should be the the length fo given number', () => {
const accountNum = faker.finance.account(16);