aboutsummaryrefslogtreecommitdiff
path: root/test/modules
diff options
context:
space:
mode:
authorCoolPlayLin <[email protected]>2023-09-24 01:45:34 +0800
committerGitHub <[email protected]>2023-09-23 17:45:34 +0000
commit74eecccd3af702d8a1d8072f94032ccb54293cb1 (patch)
tree0d09c82f95f21bc16d9664ff28494b1bde9b7d40 /test/modules
parent48a7f54caaaded0a50b3729473e9a6627440fabb (diff)
downloadfaker-74eecccd3af702d8a1d8072f94032ccb54293cb1.tar.xz
faker-74eecccd3af702d8a1d8072f94032ccb54293cb1.zip
feat(locale): add unionpay credit card for zh_CN (#2338)
Diffstat (limited to 'test/modules')
-rw-r--r--test/modules/finance.spec.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/modules/finance.spec.ts b/test/modules/finance.spec.ts
index a783f073..d5de1817 100644
--- a/test/modules/finance.spec.ts
+++ b/test/modules/finance.spec.ts
@@ -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';
@@ -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}$/);