Skip to content

Commit

Permalink
chore: import validator functions individually (#3274)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Nov 21, 2024
1 parent 3e1f26c commit 56acea3
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 76 deletions.
12 changes: 6 additions & 6 deletions test/modules/commerce.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import validator from 'validator';
import { isISBN } from 'validator';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from '../support/seeded-runs';
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('commerce', () => {
isbn,
'The expected match should be ISBN-13 with hyphens'
).toMatch(/^978-[01]-[\d-]{9}-\d$/);
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 13));
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 13));
});

it('should return ISBN-10 with hyphen separators when passing variant 10 as argument', () => {
Expand All @@ -214,7 +214,7 @@ describe('commerce', () => {
isbn,
'The expected match should be ISBN-10 with hyphens'
).toMatch(/^[01]-[\d-]{9}-[\dX]$/);
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 10));
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 10));
});

it('should return ISBN-13 with hyphen separators when passing variant 13 as argument', () => {
Expand All @@ -224,7 +224,7 @@ describe('commerce', () => {
isbn,
'The expected match should be ISBN-13 with hyphens'
).toMatch(/^978-[01]-[\d-]{9}-\d$/);
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 13));
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 13));
});

it('should return ISBN-10 with space separators when passing variant 10 and space separators as argument', () => {
Expand All @@ -234,7 +234,7 @@ describe('commerce', () => {
isbn,
'The expected match should be ISBN-10 with space separators'
).toMatch(/^[01] [\d ]{9} [\dX]$/);
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 10));
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 10));
});

it('should return ISBN-13 with space separators when passing space separators as argument', () => {
Expand All @@ -244,7 +244,7 @@ describe('commerce', () => {
isbn,
'The expected match should be ISBN-13 with space separators'
).toMatch(/^978 [01] [\d ]{9} \d$/);
expect(isbn).toSatisfy((isbn: string) => validator.isISBN(isbn, 13));
expect(isbn).toSatisfy((isbn: string) => isISBN(isbn, 13));
});
});
}
Expand Down
16 changes: 8 additions & 8 deletions test/modules/finance-iban.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import validator from 'validator';
import { isIBAN } from 'validator';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { prettyPrintIban } from '../../src/modules/finance';
Expand All @@ -17,7 +17,7 @@ describe('finance_iban', () => {
});

expect(actual).toMatch(new RegExp(`^${country}`));
expect(actual).toSatisfy(validator.isIBAN);
expect(actual).toSatisfy(isIBAN);
});
});

Expand All @@ -41,7 +41,7 @@ describe('finance_iban', () => {
countryCode: 'GE',
});

expect(iban).toSatisfy(validator.isIBAN);
expect(iban).toSatisfy(isIBAN);

const ibanFormatted = prettyPrintIban(iban);
const bban = iban.substring(4) + iban.substring(0, 4);
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('finance_iban', () => {
countryCode: 'PK',
});

expect(iban).toSatisfy(validator.isIBAN);
expect(iban).toSatisfy(isIBAN);

const ibanFormated = prettyPrintIban(iban);
const bban = iban.substring(4) + iban.substring(0, 4);
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('finance_iban', () => {
countryCode: 'TR',
});

expect(iban).toSatisfy(validator.isIBAN);
expect(iban).toSatisfy(isIBAN);

const ibanFormated = prettyPrintIban(iban);
const bban = iban.substring(4) + iban.substring(0, 4);
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('finance_iban', () => {
countryCode: 'AZ',
});

expect(iban).toSatisfy(validator.isIBAN);
expect(iban).toSatisfy(isIBAN);

const ibanFormated = prettyPrintIban(iban);
const bban = iban.substring(4) + iban.substring(0, 4);
Expand Down Expand Up @@ -308,7 +308,7 @@ describe('finance_iban', () => {
countryCode: 'CR',
});

expect(iban).toSatisfy(validator.isIBAN);
expect(iban).toSatisfy(isIBAN);

const ibanFormated = prettyPrintIban(iban);
const bban = iban.substring(4) + iban.substring(0, 4);
Expand Down Expand Up @@ -360,7 +360,7 @@ describe('finance_iban', () => {
});
const ibanFormated = prettyPrintIban(iban);

expect(iban).toSatisfy(validator.isIBAN);
expect(iban).toSatisfy(isIBAN);

expect(
28,
Expand Down
10 changes: 5 additions & 5 deletions test/modules/git.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import validator from 'validator';
import { isEmail, isHexadecimal, isSlug } from 'validator';
import { describe, expect, it } from 'vitest';
import { faker } from '../../src';
import { seededTests } from '../support/seeded-runs';
Expand All @@ -13,7 +13,7 @@ function isValidCommitAuthor(email: string): boolean {
// that contain unquoted characters like . output by Git so we need
// to quote the display name
const quotedEmail = email.replace(/^(.*) </, '"$1" <');
return validator.isEmail(quotedEmail, {
return isEmail(quotedEmail, {
require_display_name: true,
});
}
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('git', () => {

expect(branch).toBeTruthy();
expect(branch).toBeTypeOf('string');
expect(branch).toSatisfy(validator.isSlug);
expect(branch).toSatisfy(isSlug);
});
});

Expand Down Expand Up @@ -145,7 +145,7 @@ describe('git', () => {

expect(commitSha).toBeTruthy();
expect(commitSha).toBeTypeOf('string');
expect(commitSha).toSatisfy(validator.isHexadecimal);
expect(commitSha).toSatisfy(isHexadecimal);
expect(commitSha).toHaveLength(40);
});

Expand All @@ -159,7 +159,7 @@ describe('git', () => {

expect(commitSha).toBeTruthy();
expect(commitSha).toBeTypeOf('string');
expect(commitSha).toSatisfy(validator.isHexadecimal);
expect(commitSha).toSatisfy(isHexadecimal);
expect(commitSha).toHaveLength(length);
}
);
Expand Down
Loading

0 comments on commit 56acea3

Please sign in to comment.