Skip to content

Commit

Permalink
Merge branch 'main' into test-new-faker-instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Mar 23, 2022
2 parents 6d0cb32 + 3f3de78 commit 8e4d8ee
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ coverage:
default:
target: 95%
threshold: 2%
patch:
default:
target: 95%
threshold: 1%
35 changes: 23 additions & 12 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ const sidebar = {
],
};

// grab from process.env once this is building on netlify
const algolia = {
apiKey: '',
indexName: '',
searchParameters: {
facetFilters: [''],
},
apiKey: process.env.API_KEY,
appId: process.env.APP_ID,
indexName: 'fakerjs',
};

const description =
Expand All @@ -62,27 +59,42 @@ export default defineConfig({
[
'meta',
{
property: 'og:description',
name: 'og:description',
content: description,
},
],
[
'meta',
{
name: 'twitter:description',
content: description,
},
],
[
'meta',
{
name: 'description',
content: description,
},
],
[
'meta',
{
property: 'og:image',
name: 'og:image',
content: image,
},
],
[
'meta',
{
property: 'twitter:image',
name: 'twitter:image',
content: image,
},
],
[
'meta',
{
property: 'twitter:card',
name: 'twitter:card',
content: 'summary_large_image',
},
],
Expand All @@ -96,7 +108,6 @@ export default defineConfig({
editLinkText: 'Suggest changes to this page',
nav,
sidebar,
// TODO 2022-03-06: https://github.com/faker-js/faker/issues/222
// algolia,
algolia,
},
});
8 changes: 6 additions & 2 deletions src/iban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,12 @@ export = {
},
{
country: 'CR',
total: 21,
total: 22,
bban: [
{
type: 'n',
count: 1,
},
{
type: 'n',
count: 3,
Expand All @@ -217,7 +221,7 @@ export = {
count: 14,
},
],
format: 'CRkk bbbc cccc cccc cccc c',
format: 'CRkk xbbb cccc cccc cccc cc',
},
{
country: 'HR',
Expand Down
44 changes: 44 additions & 0 deletions test/finance_iban.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,50 @@ describe('finance_iban', () => {
'the result should be equal to 1'
).toBe(1);
});

it('IBAN for Costa Rica is correct', () => {
// Costa Rica
// https://wise.com/us/iban/costa-rica
// Length 22
// BBAN 1n,3n,14n
// CRkk xbbb cccc cccc cccc cccc cccc
// x = reserve digit
// b = National bank code (digits)
// c = Account number (digits)

// example IBAN CR05 0152 0200 1026 2840 66

const iban = faker.finance.iban(false, 'CR');

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

const ibanFormated = iban.match(/.{1,4}/g).join(' ');
const bban = iban.substring(4) + iban.substring(0, 4);

expect(
22,
`CR IBAN would be 22 chars length, given is ${iban.length}`
).toBe(iban.length);

expect(
iban.substring(0, 2),
iban.substring(0, 2) +
"must start with 'CR' in CR IBAN " +
ibanFormated
).to.eq('CR');

expect(
iban.substring(2, 22),
iban.substring(2, 22) +
' must contains only digit in AZ IBAN ' +
ibanFormated
).match(/^\d{20}$/);

expect(
ibanLib.mod97(ibanLib.toDigitString(bban)),
'the result should be equal to 1'
).toBe(1);
});
});
}
});
Expand Down

0 comments on commit 8e4d8ee

Please sign in to comment.