Skip to content

Commit

Permalink
refactor(finance)!: simplify account implementation (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Apr 3, 2023
1 parent edc50b6 commit de078de
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
14 changes: 2 additions & 12 deletions src/modules/finance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

/**
Expand Down
10 changes: 0 additions & 10 deletions test/finance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit de078de

Please sign in to comment.