Skip to content

Commit

Permalink
test: use validator.isBIC() instead of regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ejcheng committed Sep 20, 2022
1 parent 820aca1 commit c8dc7d2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/finance.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import validator from 'validator';
import { afterEach, describe, expect, it } from 'vitest';
import { faker } from '../src';
import { FakerError } from '../src/errors/faker-error';
Expand Down Expand Up @@ -487,17 +488,15 @@ describe('finance', () => {
const bic = faker.finance.bic();

expect(bic).toBeTypeOf('string');
bic.length === 8
? expect(bic).toMatch(/^[A-Z]{6}[A-Z0-9]{2}$/)
: expect(bic).toMatch(/^[A-Z]{6}[A-Z0-9]{2}[A-Z0-9]{3}$/);
expect(bic).toSatisfy(validator.isBIC);
expect(ibanLib.iso3166).toContain(bic.substring(4, 6));
});

it('should return a BIC number with branch code', () => {
const bic = faker.finance.bic({ includeBranchCode: true });

expect(bic).toBeTypeOf('string');
expect(bic).toMatch(/^[A-Z]{6}[A-Z0-9]{2}[A-Z0-9]{3}$/);
expect(bic).toSatisfy(validator.isBIC);
expect(ibanLib.iso3166).toContain(bic.substring(4, 6));
});
});
Expand Down

0 comments on commit c8dc7d2

Please sign in to comment.