File tree Expand file tree Collapse file tree
src/locales/zh_CN/finance/credit_card Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 */
55import type { FinanceDefinition } from '../../../..' ;
66import mastercard from './mastercard' ;
7+ import unionpay from './unionpay' ;
78import visa from './visa' ;
89
910const credit_card : FinanceDefinition [ 'credit_card' ] = {
1011 mastercard,
12+ unionpay,
1113 visa,
1214} ;
1315
Original file line number Diff line number Diff line change 1+ export default [
2+ '62#############L' ,
3+ '67#############L' ,
4+ '81#############L' ,
5+ '81##############L' ,
6+ '81###############L' ,
7+ '81################L' ,
8+ ] ;
Original file line number Diff line number Diff line change 11import isValidBtcAddress from 'validator/lib/isBtcAddress' ;
2+ import isCreditCard from 'validator/lib/isCreditCard' ;
23import { describe , expect , it } from 'vitest' ;
3- import { faker } from '../../src' ;
4+ import { faker , fakerZH_CN } from '../../src' ;
45import { FakerError } from '../../src/errors/faker-error' ;
56import ibanLib from '../../src/modules/finance/iban' ;
67import { luhnCheck } from '../../src/modules/helpers/luhn-check' ;
@@ -476,6 +477,14 @@ describe('finance', () => {
476477 expect ( maestro ) . toSatisfy ( luhnCheck ) ;
477478 } ) ;
478479
480+ it ( 'should generate a valid union pay credit card' , ( ) => {
481+ const actual = fakerZH_CN . finance . creditCardNumber ( 'unionpay' ) ;
482+ expect ( actual ) . toSatisfy ( luhnCheck ) ;
483+ expect ( actual ) . toSatisfy ( ( value ) =>
484+ isCreditCard ( value as string , { provider : 'unionpay' } )
485+ ) ;
486+ } ) ;
487+
479488 it ( 'should return custom formatted strings' , ( ) => {
480489 let number = faker . finance . creditCardNumber ( '###-###-##L' ) ;
481490 expect ( number ) . toMatch ( / ^ \d { 3 } \- \d { 3 } \- \d { 3 } $ / ) ;
You can’t perform that action at this time.
0 commit comments