diff options
| author | DivisionByZero <[email protected]> | 2023-02-15 10:14:49 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-02-15 09:14:49 +0000 |
| commit | 1399375686afb99a4ea55a6153601905f395304d (patch) | |
| tree | 2501785322b7663d5e5bfb18ff445e00a748a3cd /test | |
| parent | 8f2d5c8a6d5c733e0dde6efdd3a5e058d372ee07 (diff) | |
| download | faker-1399375686afb99a4ea55a6153601905f395304d.tar.xz faker-1399375686afb99a4ea55a6153601905f395304d.zip | |
refactor(finance): standardize arguments (#1821)
Diffstat (limited to 'test')
| -rw-r--r-- | test/__snapshots__/finance.spec.ts.snap | 114 | ||||
| -rw-r--r-- | test/finance.spec.ts | 72 |
2 files changed, 155 insertions, 31 deletions
diff --git a/test/__snapshots__/finance.spec.ts.snap b/test/__snapshots__/finance.spec.ts.snap index 937b84ef..e3736cc8 100644 --- a/test/__snapshots__/finance.spec.ts.snap +++ b/test/__snapshots__/finance.spec.ts.snap @@ -4,17 +4,29 @@ exports[`finance > 42 > account > noArgs 1`] = `"37917755"`; exports[`finance > 42 > account > with length 1`] = `"3791775514"`; +exports[`finance > 42 > account > with length option 1`] = `"3791775514"`; + exports[`finance > 42 > accountName 1`] = `"Money Market Account"`; exports[`finance > 42 > amount > noArgs 1`] = `"374.54"`; -exports[`finance > 42 > amount > with dec 1`] = `"374.54011"`; +exports[`finance > 42 > amount > with leagcy dec 1`] = `"374.54011"`; -exports[`finance > 42 > amount > with max 1`] = `"18.73"`; +exports[`finance > 42 > amount > with leagcy max 1`] = `"18.73"`; exports[`finance > 42 > amount > with min 1`] = `"380.79"`; -exports[`finance > 42 > amount > with min and max and dec and symbol 1`] = `"$24.98161"`; +exports[`finance > 42 > amount > with min and max option 1`] = `"24.98"`; + +exports[`finance > 42 > amount > with min option 1`] = `"380.79"`; + +exports[`finance > 42 > amount > with min, leagcy max, leagcy dec and leagcy symbol 1`] = `"$24.98161"`; + +exports[`finance > 42 > amount > with min, max and dec option 1`] = `"24.98161"`; + +exports[`finance > 42 > amount > with min, max, dec and symbol option 1`] = `"#24.98161"`; + +exports[`finance > 42 > amount > with min, max, dec, symbol and autoFormat option 1`] = `"#24.98161"`; exports[`finance > 42 > bic > noArgs 1`] = `"UYETSCLLG53"`; @@ -30,6 +42,8 @@ exports[`finance > 42 > creditCardNumber > noArgs 1`] = `"3581-7755-1410-0484"`; exports[`finance > 42 > creditCardNumber > with issuer 1`] = `"4791775514102"`; +exports[`finance > 42 > creditCardNumber > with issuer option 1`] = `"4791775514102"`; + exports[`finance > 42 > currencyCode 1`] = `"IQD"`; exports[`finance > 42 > currencyName 1`] = `"Iraqi Dinar"`; @@ -44,22 +58,34 @@ exports[`finance > 42 > iban > with formatted 1`] = `"GT03 9751 1086 7098 F1E3 5 exports[`finance > 42 > iban > with formatted and countryCode 1`] = `"DE47 7175 0020 0086 0600 97"`; +exports[`finance > 42 > iban > with formatted and countryCode option 1`] = `"DE47 7175 0020 0086 0600 97"`; + +exports[`finance > 42 > iban > with formatted option 1`] = `"GT03 9751 1086 7098 F1E3 5426 12J4"`; + exports[`finance > 42 > litecoinAddress 1`] = `"3XbJMAAara64sSkA9HD24YHQWd1b"`; exports[`finance > 42 > mask > noArgs 1`] = `"(...3791)"`; -exports[`finance > 42 > mask > with ellipsis 1`] = `"(...3791)"`; +exports[`finance > 42 > mask > with legacy ellipsis 1`] = `"(...3791)"`; + +exports[`finance > 42 > mask > with legacy parenthesis 1`] = `"(...3791)"`; exports[`finance > 42 > mask > with length 1`] = `"(...37917)"`; -exports[`finance > 42 > mask > with length, parenthesis, and ellipsis 1`] = `"(...37917)"`; +exports[`finance > 42 > mask > with length and parenthesis option 1`] = `"...37917"`; -exports[`finance > 42 > mask > with parenthesis 1`] = `"(...3791)"`; +exports[`finance > 42 > mask > with length option 1`] = `"(...37917)"`; + +exports[`finance > 42 > mask > with length, legacy parenthesis, and legacy ellipsis 1`] = `"(...37917)"`; + +exports[`finance > 42 > mask > with length, parenthesis and ellipsis option 1`] = `"...37917"`; exports[`finance > 42 > pin > noArgs 1`] = `"3791"`; exports[`finance > 42 > pin > with length 1`] = `"3791775514"`; +exports[`finance > 42 > pin > with length option 1`] = `"3791775514"`; + exports[`finance > 42 > routingNumber 1`] = `"379177554"`; exports[`finance > 42 > transactionDescription 1`] = `"invoice transaction at Wiegand, Deckow and Reynolds using card ending with ***(...8361) for SDG 374.54 in account ***55141004"`; @@ -70,17 +96,29 @@ exports[`finance > 1211 > account > noArgs 1`] = `"94872190"`; exports[`finance > 1211 > account > with length 1`] = `"9487219061"`; +exports[`finance > 1211 > account > with length option 1`] = `"9487219061"`; + exports[`finance > 1211 > accountName 1`] = `"Personal Loan Account"`; exports[`finance > 1211 > amount > noArgs 1`] = `"928.52"`; -exports[`finance > 1211 > amount > with dec 1`] = `"928.52016"`; +exports[`finance > 1211 > amount > with leagcy dec 1`] = `"928.52016"`; -exports[`finance > 1211 > amount > with max 1`] = `"46.43"`; +exports[`finance > 1211 > amount > with leagcy max 1`] = `"46.43"`; exports[`finance > 1211 > amount > with min 1`] = `"929.24"`; -exports[`finance > 1211 > amount > with min and max and dec and symbol 1`] = `"$47.14081"`; +exports[`finance > 1211 > amount > with min and max option 1`] = `"47.15"`; + +exports[`finance > 1211 > amount > with min option 1`] = `"929.24"`; + +exports[`finance > 1211 > amount > with min, leagcy max, leagcy dec and leagcy symbol 1`] = `"$47.14081"`; + +exports[`finance > 1211 > amount > with min, max and dec option 1`] = `"47.14081"`; + +exports[`finance > 1211 > amount > with min, max, dec and symbol option 1`] = `"#47.14081"`; + +exports[`finance > 1211 > amount > with min, max, dec, symbol and autoFormat option 1`] = `"#47.14081"`; exports[`finance > 1211 > bic > noArgs 1`] = `"LXUFBTZ1"`; @@ -96,6 +134,8 @@ exports[`finance > 1211 > creditCardNumber > noArgs 1`] = `"4872190616274"`; exports[`finance > 1211 > creditCardNumber > with issuer 1`] = `"4487-2190-6162-7436"`; +exports[`finance > 1211 > creditCardNumber > with issuer option 1`] = `"4487-2190-6162-7436"`; + exports[`finance > 1211 > currencyCode 1`] = `"XDR"`; exports[`finance > 1211 > currencyName 1`] = `"SDR"`; @@ -110,22 +150,34 @@ exports[`finance > 1211 > iban > with formatted 1`] = `"TN42 8201 6024 1706 7929 exports[`finance > 1211 > iban > with formatted and countryCode 1`] = `"DE41 4700 9026 0417 0679 42"`; +exports[`finance > 1211 > iban > with formatted and countryCode option 1`] = `"DE41 4700 9026 0417 0679 42"`; + +exports[`finance > 1211 > iban > with formatted option 1`] = `"TN42 8201 6024 1706 7929 9006"`; + exports[`finance > 1211 > litecoinAddress 1`] = `"MTMe8Z3EaFdLqmaGKP1LEEJQVriSZRZds"`; exports[`finance > 1211 > mask > noArgs 1`] = `"(...9487)"`; -exports[`finance > 1211 > mask > with ellipsis 1`] = `"(...9487)"`; +exports[`finance > 1211 > mask > with legacy ellipsis 1`] = `"(...9487)"`; + +exports[`finance > 1211 > mask > with legacy parenthesis 1`] = `"(...9487)"`; exports[`finance > 1211 > mask > with length 1`] = `"(...94872)"`; -exports[`finance > 1211 > mask > with length, parenthesis, and ellipsis 1`] = `"(...94872)"`; +exports[`finance > 1211 > mask > with length and parenthesis option 1`] = `"...94872"`; + +exports[`finance > 1211 > mask > with length option 1`] = `"(...94872)"`; + +exports[`finance > 1211 > mask > with length, legacy parenthesis, and legacy ellipsis 1`] = `"(...94872)"`; -exports[`finance > 1211 > mask > with parenthesis 1`] = `"(...9487)"`; +exports[`finance > 1211 > mask > with length, parenthesis and ellipsis option 1`] = `"...94872"`; exports[`finance > 1211 > pin > noArgs 1`] = `"9487"`; exports[`finance > 1211 > pin > with length 1`] = `"9487219061"`; +exports[`finance > 1211 > pin > with length option 1`] = `"9487219061"`; + exports[`finance > 1211 > routingNumber 1`] = `"948721904"`; exports[`finance > 1211 > transactionDescription 1`] = `"deposit transaction at Trantow - Satterfield using card ending with ***(...4316) for STN 928.52 in account ***19061627"`; @@ -136,17 +188,29 @@ exports[`finance > 1337 > account > noArgs 1`] = `"25122540"`; exports[`finance > 1337 > account > with length 1`] = `"2512254032"`; +exports[`finance > 1337 > account > with length option 1`] = `"2512254032"`; + exports[`finance > 1337 > accountName 1`] = `"Money Market Account"`; exports[`finance > 1337 > amount > noArgs 1`] = `"262.02"`; -exports[`finance > 1337 > amount > with dec 1`] = `"262.02467"`; +exports[`finance > 1337 > amount > with leagcy dec 1`] = `"262.02467"`; -exports[`finance > 1337 > amount > with max 1`] = `"13.10"`; +exports[`finance > 1337 > amount > with leagcy max 1`] = `"13.10"`; exports[`finance > 1337 > amount > with min 1`] = `"269.40"`; -exports[`finance > 1337 > amount > with min and max and dec and symbol 1`] = `"$20.48099"`; +exports[`finance > 1337 > amount > with min and max option 1`] = `"20.48"`; + +exports[`finance > 1337 > amount > with min option 1`] = `"269.40"`; + +exports[`finance > 1337 > amount > with min, leagcy max, leagcy dec and leagcy symbol 1`] = `"$20.48099"`; + +exports[`finance > 1337 > amount > with min, max and dec option 1`] = `"20.48099"`; + +exports[`finance > 1337 > amount > with min, max, dec and symbol option 1`] = `"#20.48099"`; + +exports[`finance > 1337 > amount > with min, max, dec, symbol and autoFormat option 1`] = `"#20.48099"`; exports[`finance > 1337 > bic > noArgs 1`] = `"OEFHLYG18IL"`; @@ -162,6 +226,8 @@ exports[`finance > 1337 > creditCardNumber > noArgs 1`] = `"6011-6212-2540-3255- exports[`finance > 1337 > creditCardNumber > with issuer 1`] = `"4512254032550"`; +exports[`finance > 1337 > creditCardNumber > with issuer option 1`] = `"4512254032550"`; + exports[`finance > 1337 > currencyCode 1`] = `"FJD"`; exports[`finance > 1337 > currencyName 1`] = `"Fiji Dollar"`; @@ -176,22 +242,34 @@ exports[`finance > 1337 > iban > with formatted 1`] = `"FO56 1005 0250 0903 18"` exports[`finance > 1337 > iban > with formatted and countryCode 1`] = `"DE04 0200 5032 5009 0304 06"`; +exports[`finance > 1337 > iban > with formatted and countryCode option 1`] = `"DE04 0200 5032 5009 0304 06"`; + +exports[`finance > 1337 > iban > with formatted option 1`] = `"FO56 1005 0250 0903 18"`; + exports[`finance > 1337 > litecoinAddress 1`] = `"Madhxs2jewAgkYgJi7No6Cn8JZar"`; exports[`finance > 1337 > mask > noArgs 1`] = `"(...2512)"`; -exports[`finance > 1337 > mask > with ellipsis 1`] = `"(...2512)"`; +exports[`finance > 1337 > mask > with legacy ellipsis 1`] = `"(...2512)"`; + +exports[`finance > 1337 > mask > with legacy parenthesis 1`] = `"(...2512)"`; exports[`finance > 1337 > mask > with length 1`] = `"(...25122)"`; -exports[`finance > 1337 > mask > with length, parenthesis, and ellipsis 1`] = `"(...25122)"`; +exports[`finance > 1337 > mask > with length and parenthesis option 1`] = `"...25122"`; + +exports[`finance > 1337 > mask > with length option 1`] = `"(...25122)"`; -exports[`finance > 1337 > mask > with parenthesis 1`] = `"(...2512)"`; +exports[`finance > 1337 > mask > with length, legacy parenthesis, and legacy ellipsis 1`] = `"(...25122)"`; + +exports[`finance > 1337 > mask > with length, parenthesis and ellipsis option 1`] = `"...25122"`; exports[`finance > 1337 > pin > noArgs 1`] = `"2512"`; exports[`finance > 1337 > pin > with length 1`] = `"2512254032"`; +exports[`finance > 1337 > pin > with length option 1`] = `"2512254032"`; + exports[`finance > 1337 > routingNumber 1`] = `"251225401"`; exports[`finance > 1337 > transactionDescription 1`] = `"withdrawal transaction at Cronin - Effertz using card ending with ***(...3927) for GTQ 262.02 in account ***54032552"`; diff --git a/test/finance.spec.ts b/test/finance.spec.ts index 7c90a62a..f5f640d7 100644 --- a/test/finance.spec.ts +++ b/test/finance.spec.ts @@ -29,19 +29,46 @@ describe('finance', () => { 'transactionDescription' ); - t.describeEach( - 'account', - 'pin' - )((t) => { - t.it('noArgs').it('with length', 10); + t.describe('account', (t) => { + t.it('noArgs') + .it('with length', 10) + .it('with length option', { length: 10 }); + }); + + t.describe('pin', (t) => { + t.it('noArgs') + .it('with length', 10) + .it('with length option', { length: 10 }); }); t.describe('amount', (t) => { t.it('noArgs') + .it('with min option', { min: 10 }) + .it('with min and max option', { min: 10, max: 50 }) + .it('with min, max and dec option', { min: 10, max: 50, dec: 5 }) + .it('with min, max, dec and symbol option', { + min: 10, + max: 50, + dec: 5, + symbol: '#', + }) + .it('with min, max, dec, symbol and autoFormat option', { + min: 10, + max: 50, + dec: 5, + symbol: '#', + autoFormat: false, + }) .it('with min', 10) - .it('with max', undefined, 50) - .it('with dec', undefined, undefined, 5) - .it('with min and max and dec and symbol', 10, 50, 5, '$'); + .it('with leagcy max', undefined, 50) + .it('with leagcy dec', undefined, undefined, 5) + .it( + 'with min, leagcy max, leagcy dec and leagcy symbol', + 10, + 50, + 5, + '$' + ); }); t.describe('bic', (t) => { @@ -50,20 +77,39 @@ describe('finance', () => { t.describe('iban', (t) => { t.it('noArgs') + .it('with formatted option', { formatted: true }) + .it('with formatted and countryCode option', { + formatted: true, + countryCode: 'DE', + }) .it('with formatted', true) .it('with formatted and countryCode', true, 'DE'); }); t.describe('creditCardNumber', (t) => { - t.it('noArgs').it('with issuer', 'visa'); + t.it('noArgs') + .it('with issuer', 'visa') + .it('with issuer option', { issuer: 'visa' }); }); t.describe('mask', (t) => { t.it('noArgs') .it('with length', 5) - .it('with parenthesis', undefined, true) - .it('with ellipsis', undefined, undefined, true) - .it('with length, parenthesis, and ellipsis', 5, true, true); + .it('with legacy parenthesis', undefined, true) + .it('with legacy ellipsis', undefined, undefined, true) + .it( + 'with length, legacy parenthesis, and legacy ellipsis', + 5, + true, + true + ) + .it('with length option', { length: 5 }) + .it('with length and parenthesis option', { length: 5, parens: false }) + .it('with length, parenthesis and ellipsis option', { + length: 5, + parens: false, + ellipsis: true, + }); }); }); @@ -121,7 +167,7 @@ describe('finance', () => { describe('mask()', () => { it('should set a default length', () => { const expected = 4; //default account mask length - const mask = faker.finance.mask(null, false, false); + const mask = faker.finance.mask(undefined, false, false); expect( mask, |
