Skip to content

Commit 04e4346

Browse files
authored
test: use [email protected] with isULID, isISO31661Numeric, isISO15924 (#3482)
1 parent 242cc79 commit 04e4346

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"@types/node": "22.14.1",
113113
"@types/sanitize-html": "2.15.0",
114114
"@types/semver": "7.7.0",
115-
"@types/validator": "13.12.3",
115+
"@types/validator": "13.15.0",
116116
"@vitest/coverage-v8": "3.1.1",
117117
"@vitest/eslint-plugin": "1.1.42",
118118
"@vitest/ui": "3.1.1",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/locale-imports.spec.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import isISO15924 from 'validator/lib/isISO15924';
12
import { describe, expect, it } from 'vitest';
23
import type { Faker } from '../src';
34
import { allLocales } from '../src';
@@ -43,24 +44,7 @@ describe.each(keys(allLocales))('locale imports', (locale) => {
4344
expect(metadata.language).toBeTypeOf('string');
4445
expect(metadata.language).toMatch(/^[a-z]{2}$/);
4546
expect(metadata.script).toBeTypeOf('string');
46-
expect([
47-
'Arab',
48-
'Armn',
49-
'Beng',
50-
'Cyrl',
51-
'Deva',
52-
'Geor',
53-
'Grek',
54-
'Hans',
55-
'Hant',
56-
'Hebr',
57-
'Jpan',
58-
'Kore',
59-
'Latn',
60-
'Taml',
61-
'Thaa',
62-
'Thai',
63-
]).toContain(metadata.script);
47+
expect(metadata.script).toSatisfy(isISO15924);
6448
expect(metadata.endonym).toBeTypeOf('string');
6549
expect(metadata.dir).toBeTypeOf('string');
6650
expect(['ltr', 'rtl']).toContain(metadata.dir);

test/modules/location.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import isISO31661Alpha2 from 'validator/lib/isISO31661Alpha2';
2+
import isISO31661Alpha3 from 'validator/lib/isISO31661Alpha3';
3+
import isISO31661Numeric from 'validator/lib/isISO31661Numeric';
14
import { describe, expect, it } from 'vitest';
25
import {
36
FakerError,
@@ -165,20 +168,23 @@ describe('location', () => {
165168

166169
expect(countryCode).toBeTruthy();
167170
expect(countryCode).toMatch(/^[A-Z]{2}$/);
171+
expect(countryCode).toSatisfy(isISO31661Alpha2);
168172
});
169173

170174
it('returns random alpha-3 countryCode', () => {
171175
const countryCode = faker.location.countryCode('alpha-3');
172176

173177
expect(countryCode).toBeTruthy();
174178
expect(countryCode).toMatch(/^[A-Z]{3}$/);
179+
expect(countryCode).toSatisfy(isISO31661Alpha3);
175180
});
176181

177182
it('returns random numeric countryCode', () => {
178183
const countryCode = faker.location.countryCode('numeric');
179184

180185
expect(countryCode).toBeTruthy();
181186
expect(countryCode).toMatch(/^\d{3}$/);
187+
expect(countryCode).toSatisfy(isISO31661Numeric);
182188
});
183189
});
184190

test/modules/string.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import isULID from 'validator/lib/isULID';
12
import { describe, expect, it } from 'vitest';
23
import { FakerError, faker } from '../../src';
34
import { seededTests } from '../support/seeded-runs';
@@ -774,6 +775,7 @@ describe('string', () => {
774775
const ulid = faker.string.ulid();
775776
const regex = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/;
776777
expect(ulid).toMatch(regex);
778+
expect(ulid).toSatisfy(isULID);
777779
});
778780
});
779781

0 commit comments

Comments
 (0)