Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(locale): add unionpay module for zh_CN #2338

Merged
merged 24 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e3ae97b
feat(locale): add finance module for zh_CN
CoolPlayLin Aug 23, 2023
71887d2
Merge branch 'next' into finance_zh_CN
CoolPlayLin Aug 24, 2023
4edc631
Merge branch 'next' into finance_zh_CN
CoolPlayLin Aug 24, 2023
2874503
Merge branch 'next' into finance_zh_CN
ST-DDT Aug 26, 2023
b029d68
Merge branch 'next' into finance_zh_CN
CoolPlayLin Aug 28, 2023
d81fe57
Merge branch 'next' into finance_zh_CN
CoolPlayLin Aug 28, 2023
7b7fd3f
Merge branch 'next' into finance_zh_CN
CoolPlayLin Sep 1, 2023
29d2d62
I don't know why it fails
CoolPlayLin Sep 1, 2023
a18432d
Merge branch 'finance_zh_CN' of https://github.com/CoolPlayLin/faker …
CoolPlayLin Sep 1, 2023
0d2d338
🌟
CoolPlayLin Sep 1, 2023
3bb7bb8
Merge branch 'next' into finance_zh_CN
CoolPlayLin Sep 1, 2023
42dc72d
Merge branch 'next' into finance_zh_CN
CoolPlayLin Sep 10, 2023
4b85a68
Merge branch 'finance_zh_CN' of https://github.com/CoolPlayLin/faker …
CoolPlayLin Sep 10, 2023
ba2455d
Merge branch 'next' into finance_zh_CN
CoolPlayLin Sep 10, 2023
f97ca42
🌟
CoolPlayLin Sep 10, 2023
9c6ed62
fix format
CoolPlayLin Sep 10, 2023
40ce360
CoolPlayLin Sep 10, 2023
e2ae327
Merge branch 'next' into finance_zh_CN
CoolPlayLin Sep 16, 2023
7813f5e
Update finance.spec.ts
CoolPlayLin Sep 16, 2023
d0d60cd
CoolPlayLin Sep 16, 2023
bf8e0b0
Merge branch 'next' into finance_zh_CN
CoolPlayLin Sep 23, 2023
a41090f
Where comes a bad file?
CoolPlayLin Sep 23, 2023
295e3f5
👻
CoolPlayLin Sep 23, 2023
192eb73
Merge branch 'next' into finance_zh_CN
ST-DDT Sep 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/locales/zh_CN/finance/credit_card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { FinanceDefinition } from '../../../..';
import unionpay from './unionpay';

const credit_card: FinanceDefinition['credit_card'] = {
unionpay,
};

export default credit_card;
8 changes: 8 additions & 0 deletions src/locales/zh_CN/finance/credit_card/unionpay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default [
'62#############L',
'67#############L',
'81#############L',
'81##############L',
'81###############L',
'81################L',
];
12 changes: 12 additions & 0 deletions src/locales/zh_CN/finance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { FinanceDefinition } from '../../..';
import credit_card from './credit_card';

const finance: FinanceDefinition = {
credit_card,
};

export default finance;
2 changes: 2 additions & 0 deletions src/locales/zh_CN/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import animal from './animal';
import color from './color';
import company from './company';
import date from './date';
import finance from './finance';
import hacker from './hacker';
import internet from './internet';
import location from './location';
Expand All @@ -21,6 +22,7 @@ const zh_CN: LocaleDefinition = {
color,
company,
date,
finance,
hacker,
internet,
location,
Expand Down
11 changes: 10 additions & 1 deletion test/modules/finance.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import isValidBtcAddress from 'validator/lib/isBtcAddress';
import isCreditCard from 'validator/lib/isCreditCard';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { faker, fakerZH_CN } from '../../src';
import { FakerError } from '../../src/errors/faker-error';
import ibanLib from '../../src/modules/finance/iban';
import { luhnCheck } from '../../src/modules/helpers/luhn-check';
Expand Down Expand Up @@ -476,6 +477,14 @@ describe('finance', () => {
expect(maestro).toSatisfy(luhnCheck);
});

it('should generate a valid union pay credit card', () => {
const actual = fakerZH_CN.finance.creditCardNumber('unionpay');
expect(actual).toSatisfy(luhnCheck);
expect(actual).toSatisfy((value) =>
isCreditCard(value as string, { provider: 'unionpay' })
);
});

it('should return custom formatted strings', () => {
let number = faker.finance.creditCardNumber('###-###-##L');
expect(number).toMatch(/^\d{3}\-\d{3}\-\d{3}$/);
Expand Down