Skip to content

Commit e0ba50b

Browse files
authored
fix(finance): maskedNumber has incorrect defaults (#2494)
1 parent 8542ef3 commit e0ba50b

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

src/modules/finance/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export class FinanceModule extends ModuleBase {
345345
options = { length: options };
346346
}
347347

348-
const { ellipsis, length = 4, parens } = options;
348+
const { ellipsis = true, length = 4, parens = true } = options;
349349

350350
let template = this.faker.string.numeric({ length });
351351

test/modules/__snapshots__/finance.spec.ts.snap

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,23 @@ exports[`finance > 42 > iban > with formatted option 1`] = `"GT03 9751 1086 7098
7878

7979
exports[`finance > 42 > litecoinAddress 1`] = `"3XbJMAAara64sSkA9HD24YHQWd1b"`;
8080

81-
exports[`finance > 42 > mask > noArgs 1`] = `"3791"`;
81+
exports[`finance > 42 > mask > noArgs 1`] = `"(...3791)"`;
8282

83-
exports[`finance > 42 > mask > with ellipsis 1`] = `"...3791"`;
83+
exports[`finance > 42 > mask > with ellipsis 1`] = `"(...3791)"`;
8484

85-
exports[`finance > 42 > mask > with length 1`] = `"37917"`;
85+
exports[`finance > 42 > mask > with length 1`] = `"(...37917)"`;
8686

8787
exports[`finance > 42 > mask > with length, parenthesis and ellipsis 1`] = `"(...37917)"`;
8888

89-
exports[`finance > 42 > mask > with parenthesis 1`] = `"(3791)"`;
89+
exports[`finance > 42 > mask > with parenthesis 1`] = `"(...3791)"`;
9090

91-
exports[`finance > 42 > maskedNumber > noArgs 1`] = `"3791"`;
91+
exports[`finance > 42 > maskedNumber > noArgs 1`] = `"(...3791)"`;
9292

93-
exports[`finance > 42 > maskedNumber > with length 1`] = `"37917"`;
93+
exports[`finance > 42 > maskedNumber > with length 1`] = `"(...37917)"`;
9494

95-
exports[`finance > 42 > maskedNumber > with length and parenthesis option 1`] = `"37917"`;
95+
exports[`finance > 42 > maskedNumber > with length and parenthesis option 1`] = `"...37917"`;
9696

97-
exports[`finance > 42 > maskedNumber > with length option 1`] = `"37917"`;
97+
exports[`finance > 42 > maskedNumber > with length option 1`] = `"(...37917)"`;
9898

9999
exports[`finance > 42 > maskedNumber > with length, parenthesis and ellipsis option 1`] = `"...37917"`;
100100

@@ -106,7 +106,7 @@ exports[`finance > 42 > pin > with length option 1`] = `"3791775514"`;
106106

107107
exports[`finance > 42 > routingNumber 1`] = `"379177554"`;
108108

109-
exports[`finance > 42 > transactionDescription 1`] = `"invoice transaction at Wiegand, Deckow and Reynolds using card ending with ***8361 for RSD 374.54 in account ***55141004"`;
109+
exports[`finance > 42 > transactionDescription 1`] = `"invoice transaction at Wiegand, Deckow and Reynolds using card ending with ***(...8361) for RSD 374.54 in account ***55141004"`;
110110

111111
exports[`finance > 42 > transactionType 1`] = `"withdrawal"`;
112112

@@ -188,23 +188,23 @@ exports[`finance > 1211 > iban > with formatted option 1`] = `"TN42 8201 6024 17
188188

189189
exports[`finance > 1211 > litecoinAddress 1`] = `"MTMe8Z3EaFdLqmaGKP1LEEJQVriSZRZds"`;
190190

191-
exports[`finance > 1211 > mask > noArgs 1`] = `"9487"`;
191+
exports[`finance > 1211 > mask > noArgs 1`] = `"(...9487)"`;
192192

193-
exports[`finance > 1211 > mask > with ellipsis 1`] = `"...9487"`;
193+
exports[`finance > 1211 > mask > with ellipsis 1`] = `"(...9487)"`;
194194

195-
exports[`finance > 1211 > mask > with length 1`] = `"94872"`;
195+
exports[`finance > 1211 > mask > with length 1`] = `"(...94872)"`;
196196

197197
exports[`finance > 1211 > mask > with length, parenthesis and ellipsis 1`] = `"(...94872)"`;
198198

199-
exports[`finance > 1211 > mask > with parenthesis 1`] = `"(9487)"`;
199+
exports[`finance > 1211 > mask > with parenthesis 1`] = `"(...9487)"`;
200200

201-
exports[`finance > 1211 > maskedNumber > noArgs 1`] = `"9487"`;
201+
exports[`finance > 1211 > maskedNumber > noArgs 1`] = `"(...9487)"`;
202202

203-
exports[`finance > 1211 > maskedNumber > with length 1`] = `"94872"`;
203+
exports[`finance > 1211 > maskedNumber > with length 1`] = `"(...94872)"`;
204204

205-
exports[`finance > 1211 > maskedNumber > with length and parenthesis option 1`] = `"94872"`;
205+
exports[`finance > 1211 > maskedNumber > with length and parenthesis option 1`] = `"...94872"`;
206206

207-
exports[`finance > 1211 > maskedNumber > with length option 1`] = `"94872"`;
207+
exports[`finance > 1211 > maskedNumber > with length option 1`] = `"(...94872)"`;
208208

209209
exports[`finance > 1211 > maskedNumber > with length, parenthesis and ellipsis option 1`] = `"...94872"`;
210210

@@ -216,7 +216,7 @@ exports[`finance > 1211 > pin > with length option 1`] = `"9487219061"`;
216216

217217
exports[`finance > 1211 > routingNumber 1`] = `"948721904"`;
218218

219-
exports[`finance > 1211 > transactionDescription 1`] = `"deposit transaction at Trantow - Satterfield using card ending with ***4316 for SDG 928.52 in account ***19061627"`;
219+
exports[`finance > 1211 > transactionDescription 1`] = `"deposit transaction at Trantow - Satterfield using card ending with ***(...4316) for SDG 928.52 in account ***19061627"`;
220220

221221
exports[`finance > 1211 > transactionType 1`] = `"invoice"`;
222222

@@ -298,23 +298,23 @@ exports[`finance > 1337 > iban > with formatted option 1`] = `"FO56 1005 0250 09
298298

299299
exports[`finance > 1337 > litecoinAddress 1`] = `"Madhxs2jewAgkYgJi7No6Cn8JZar"`;
300300

301-
exports[`finance > 1337 > mask > noArgs 1`] = `"2512"`;
301+
exports[`finance > 1337 > mask > noArgs 1`] = `"(...2512)"`;
302302

303-
exports[`finance > 1337 > mask > with ellipsis 1`] = `"...2512"`;
303+
exports[`finance > 1337 > mask > with ellipsis 1`] = `"(...2512)"`;
304304

305-
exports[`finance > 1337 > mask > with length 1`] = `"25122"`;
305+
exports[`finance > 1337 > mask > with length 1`] = `"(...25122)"`;
306306

307307
exports[`finance > 1337 > mask > with length, parenthesis and ellipsis 1`] = `"(...25122)"`;
308308

309-
exports[`finance > 1337 > mask > with parenthesis 1`] = `"(2512)"`;
309+
exports[`finance > 1337 > mask > with parenthesis 1`] = `"(...2512)"`;
310310

311-
exports[`finance > 1337 > maskedNumber > noArgs 1`] = `"2512"`;
311+
exports[`finance > 1337 > maskedNumber > noArgs 1`] = `"(...2512)"`;
312312

313-
exports[`finance > 1337 > maskedNumber > with length 1`] = `"25122"`;
313+
exports[`finance > 1337 > maskedNumber > with length 1`] = `"(...25122)"`;
314314

315-
exports[`finance > 1337 > maskedNumber > with length and parenthesis option 1`] = `"25122"`;
315+
exports[`finance > 1337 > maskedNumber > with length and parenthesis option 1`] = `"...25122"`;
316316

317-
exports[`finance > 1337 > maskedNumber > with length option 1`] = `"25122"`;
317+
exports[`finance > 1337 > maskedNumber > with length option 1`] = `"(...25122)"`;
318318

319319
exports[`finance > 1337 > maskedNumber > with length, parenthesis and ellipsis option 1`] = `"...25122"`;
320320

@@ -326,6 +326,6 @@ exports[`finance > 1337 > pin > with length option 1`] = `"2512254032"`;
326326

327327
exports[`finance > 1337 > routingNumber 1`] = `"251225401"`;
328328

329-
exports[`finance > 1337 > transactionDescription 1`] = `"withdrawal transaction at Cronin - Effertz using card ending with ***3927 for GIP 262.02 in account ***54032552"`;
329+
exports[`finance > 1337 > transactionDescription 1`] = `"withdrawal transaction at Cronin - Effertz using card ending with ***(...3927) for GIP 262.02 in account ***54032552"`;
330330

331331
exports[`finance > 1337 > transactionType 1`] = `"withdrawal"`;

test/modules/finance.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ describe('finance', () => {
217217
});
218218

219219
describe('maskedNumber()', () => {
220+
it('should return contain parenthesis, ellipsis and have a length of 4 by default', () => {
221+
const actual = faker.finance.maskedNumber();
222+
223+
expect(actual).toMatch(/\(\.{3}\d{4}\)/);
224+
});
225+
220226
it('should set a default length', () => {
221227
const expected = 4; // default account mask length
222228
const mask = faker.finance.maskedNumber({

0 commit comments

Comments
 (0)