validation-br 2.0.0-next-3 → 2.0.0-next-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/dist/test/_helpers/crc.spec.d.ts +0 -2
- package/dist/test/_helpers/crc.spec.d.ts.map +0 -1
- package/dist/test/_helpers/crc.spec.js +0 -21
- package/dist/test/_helpers/crc.spec.js.map +0 -1
- package/dist/test/_helpers/crokford.spec.d.ts +0 -2
- package/dist/test/_helpers/crokford.spec.d.ts.map +0 -1
- package/dist/test/_helpers/crokford.spec.js +0 -89
- package/dist/test/_helpers/crokford.spec.js.map +0 -1
- package/dist/test/_helpers/mask.spec.d.ts +0 -2
- package/dist/test/_helpers/mask.spec.d.ts.map +0 -1
- package/dist/test/_helpers/mask.spec.js +0 -18
- package/dist/test/_helpers/mask.spec.js.map +0 -1
- package/dist/test/_helpers/random.spec.d.ts +0 -2
- package/dist/test/_helpers/random.spec.d.ts.map +0 -1
- package/dist/test/_helpers/random.spec.js +0 -77
- package/dist/test/_helpers/random.spec.js.map +0 -1
- package/dist/test/_helpers/utils/checkRepeatedSequence.spec.d.ts +0 -2
- package/dist/test/_helpers/utils/checkRepeatedSequence.spec.d.ts.map +0 -1
- package/dist/test/_helpers/utils/checkRepeatedSequence.spec.js +0 -18
- package/dist/test/_helpers/utils/checkRepeatedSequence.spec.js.map +0 -1
- package/dist/test/_helpers/utils/clearValue.spec.d.ts +0 -2
- package/dist/test/_helpers/utils/clearValue.spec.d.ts.map +0 -1
- package/dist/test/_helpers/utils/clearValue.spec.js +0 -74
- package/dist/test/_helpers/utils/clearValue.spec.js.map +0 -1
- package/dist/test/_helpers/utils/insertAtPosition.spec.d.ts +0 -2
- package/dist/test/_helpers/utils/insertAtPosition.spec.d.ts.map +0 -1
- package/dist/test/_helpers/utils/insertAtPosition.spec.js +0 -16
- package/dist/test/_helpers/utils/insertAtPosition.spec.js.map +0 -1
- package/dist/test/_helpers/utils/removeFromPosition.spec.d.ts +0 -2
- package/dist/test/_helpers/utils/removeFromPosition.spec.d.ts.map +0 -1
- package/dist/test/_helpers/utils/removeFromPosition.spec.js +0 -16
- package/dist/test/_helpers/utils/removeFromPosition.spec.js.map +0 -1
- package/dist/test/_helpers/utils/sumElementsByMultipliers.spec.d.ts +0 -2
- package/dist/test/_helpers/utils/sumElementsByMultipliers.spec.d.ts.map +0 -1
- package/dist/test/_helpers/utils/sumElementsByMultipliers.spec.js +0 -23
- package/dist/test/_helpers/utils/sumElementsByMultipliers.spec.js.map +0 -1
- package/dist/test/_helpers/utils/sumToDV.test.d.ts +0 -2
- package/dist/test/_helpers/utils/sumToDV.test.d.ts.map +0 -1
- package/dist/test/_helpers/utils/sumToDV.test.js +0 -17
- package/dist/test/_helpers/utils/sumToDV.test.js.map +0 -1
- package/dist/test/base.spec.d.ts +0 -2
- package/dist/test/base.spec.d.ts.map +0 -1
- package/dist/test/base.spec.js +0 -12
- package/dist/test/base.spec.js.map +0 -1
- package/dist/test/carplate.spec.d.ts +0 -2
- package/dist/test/carplate.spec.d.ts.map +0 -1
- package/dist/test/carplate.spec.js +0 -95
- package/dist/test/carplate.spec.js.map +0 -1
- package/dist/test/cbi_sinter.spec.d.ts +0 -2
- package/dist/test/cbi_sinter.spec.d.ts.map +0 -1
- package/dist/test/cbi_sinter.spec.js +0 -58
- package/dist/test/cbi_sinter.spec.js.map +0 -1
- package/dist/test/cep.spec.d.ts +0 -2
- package/dist/test/cep.spec.d.ts.map +0 -1
- package/dist/test/cep.spec.js +0 -107
- package/dist/test/cep.spec.js.map +0 -1
- package/dist/test/certidao.spec.d.ts +0 -2
- package/dist/test/certidao.spec.d.ts.map +0 -1
- package/dist/test/certidao.spec.js +0 -58
- package/dist/test/certidao.spec.js.map +0 -1
- package/dist/test/cnh.spec.d.ts +0 -2
- package/dist/test/cnh.spec.d.ts.map +0 -1
- package/dist/test/cnh.spec.js +0 -74
- package/dist/test/cnh.spec.js.map +0 -1
- package/dist/test/cnpj.spec.d.ts +0 -2
- package/dist/test/cnpj.spec.d.ts.map +0 -1
- package/dist/test/cnpj.spec.js +0 -124
- package/dist/test/cnpj.spec.js.map +0 -1
- package/dist/test/cpf.spec.d.ts +0 -2
- package/dist/test/cpf.spec.d.ts.map +0 -1
- package/dist/test/cpf.spec.js +0 -75
- package/dist/test/cpf.spec.js.map +0 -1
- package/dist/test/email.spec.d.ts +0 -2
- package/dist/test/email.spec.d.ts.map +0 -1
- package/dist/test/email.spec.js +0 -19
- package/dist/test/email.spec.js.map +0 -1
- package/dist/test/index.spec.d.ts +0 -2
- package/dist/test/index.spec.d.ts.map +0 -1
- package/dist/test/index.spec.js +0 -77
- package/dist/test/index.spec.js.map +0 -1
- package/dist/test/judicial-process.spec.d.ts +0 -2
- package/dist/test/judicial-process.spec.d.ts.map +0 -1
- package/dist/test/judicial-process.spec.js +0 -147
- package/dist/test/judicial-process.spec.js.map +0 -1
- package/dist/test/nup17.spec.d.ts +0 -2
- package/dist/test/nup17.spec.d.ts.map +0 -1
- package/dist/test/nup17.spec.js +0 -86
- package/dist/test/nup17.spec.js.map +0 -1
- package/dist/test/phone.spec.d.ts +0 -2
- package/dist/test/phone.spec.d.ts.map +0 -1
- package/dist/test/phone.spec.js +0 -98
- package/dist/test/phone.spec.js.map +0 -1
- package/dist/test/pis-pasep.spec.d.ts +0 -2
- package/dist/test/pis-pasep.spec.d.ts.map +0 -1
- package/dist/test/pis-pasep.spec.js +0 -81
- package/dist/test/pis-pasep.spec.js.map +0 -1
- package/dist/test/pix-copy-paste.spec.d.ts +0 -2
- package/dist/test/pix-copy-paste.spec.d.ts.map +0 -1
- package/dist/test/pix-copy-paste.spec.js +0 -48
- package/dist/test/pix-copy-paste.spec.js.map +0 -1
- package/dist/test/pix-key.spec.d.ts +0 -2
- package/dist/test/pix-key.spec.d.ts.map +0 -1
- package/dist/test/pix-key.spec.js +0 -69
- package/dist/test/pix-key.spec.js.map +0 -1
- package/dist/test/postal-track-code.spec.d.ts +0 -2
- package/dist/test/postal-track-code.spec.d.ts.map +0 -1
- package/dist/test/postal-track-code.spec.js +0 -82
- package/dist/test/postal-track-code.spec.js.map +0 -1
- package/dist/test/renavam.spec.d.ts +0 -2
- package/dist/test/renavam.spec.d.ts.map +0 -1
- package/dist/test/renavam.spec.js +0 -76
- package/dist/test/renavam.spec.js.map +0 -1
- package/dist/test/tituloEleitor.spec.d.ts +0 -2
- package/dist/test/tituloEleitor.spec.d.ts.map +0 -1
- package/dist/test/tituloEleitor.spec.js +0 -92
- package/dist/test/tituloEleitor.spec.js.map +0 -1
- package/dist/test/uf.spec.d.ts +0 -2
- package/dist/test/uf.spec.d.ts.map +0 -1
- package/dist/test/uf.spec.js +0 -92
- package/dist/test/uf.spec.js.map +0 -1
- package/dist/test/uuid.spec.d.ts +0 -2
- package/dist/test/uuid.spec.d.ts.map +0 -1
- package/dist/test/uuid.spec.js +0 -54
- package/dist/test/uuid.spec.js.map +0 -1
- package/test/_helpers/crc.spec.ts +0 -25
- package/test/_helpers/crokford.spec.ts +0 -108
- package/test/_helpers/mask.spec.ts +0 -17
- package/test/_helpers/random.spec.ts +0 -90
- package/test/_helpers/utils/checkRepeatedSequence.spec.ts +0 -17
- package/test/_helpers/utils/clearValue.spec.ts +0 -85
- package/test/_helpers/utils/insertAtPosition.spec.ts +0 -15
- package/test/_helpers/utils/removeFromPosition.spec.ts +0 -15
- package/test/_helpers/utils/sumElementsByMultipliers.spec.ts +0 -24
- package/test/_helpers/utils/sumToDV.test.ts +0 -16
- package/test/base.spec.ts +0 -10
- package/test/carplate.spec.ts +0 -103
- package/test/cbi_sinter.spec.ts +0 -69
- package/test/cep.spec.ts +0 -143
- package/test/certidao.spec.ts +0 -66
- package/test/cnh.spec.ts +0 -91
- package/test/cnpj.spec.ts +0 -153
- package/test/cpf.spec.ts +0 -88
- package/test/email.spec.ts +0 -19
- package/test/index.spec.ts +0 -112
- package/test/judicial-process.spec.ts +0 -188
- package/test/nup17.spec.ts +0 -99
- package/test/phone.spec.ts +0 -113
- package/test/pis-pasep.spec.ts +0 -92
- package/test/pix-copy-paste.spec.ts +0 -57
- package/test/pix-key.spec.ts +0 -75
- package/test/postal-track-code.spec.ts +0 -90
- package/test/renavam.spec.ts +0 -88
- package/test/tituloEleitor.spec.ts +0 -100
- package/test/uf.spec.ts +0 -104
- package/test/uuid.spec.ts +0 -65
package/test/index.spec.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isCarPlate,
|
|
3
|
-
isCNH,
|
|
4
|
-
isCNPJ,
|
|
5
|
-
isCPF,
|
|
6
|
-
isJudicialProcess,
|
|
7
|
-
isNUP17,
|
|
8
|
-
isPhone,
|
|
9
|
-
isPIS,
|
|
10
|
-
isPixCopyPaste,
|
|
11
|
-
isPixKey,
|
|
12
|
-
isPostalTrackCode,
|
|
13
|
-
isRenavam,
|
|
14
|
-
isTituloEleitor,
|
|
15
|
-
} from '../src/main'
|
|
16
|
-
|
|
17
|
-
describe('ValidateBR', () => {
|
|
18
|
-
test('Deve importar isCNH', () => {
|
|
19
|
-
expect(isCNH).toBeDefined()
|
|
20
|
-
|
|
21
|
-
expect(isCNH('69044271146')).toBeTruthy()
|
|
22
|
-
expect(isCNH('69044271146')).toBeTruthy()
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('Deve importar isCNPJ', () => {
|
|
26
|
-
expect(isCNPJ).toBeDefined()
|
|
27
|
-
|
|
28
|
-
expect(isCNPJ('32432147000147')).toBeTruthy()
|
|
29
|
-
expect(isCNPJ('32432147000147')).toBeTruthy()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('Deve importar isCPF', () => {
|
|
33
|
-
expect(isCPF).toBeDefined()
|
|
34
|
-
|
|
35
|
-
expect(isCPF('15886489070')).toBeTruthy()
|
|
36
|
-
expect(isCPF('15886489070')).toBeTruthy()
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test('Deve importar isJudicialProcess', () => {
|
|
40
|
-
expect(isJudicialProcess).toBeDefined()
|
|
41
|
-
|
|
42
|
-
expect(isJudicialProcess('08002732820164058400')).toBeTruthy()
|
|
43
|
-
expect(isJudicialProcess('08002732820164058400')).toBeTruthy()
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
test('Deve importar isNUP17', () => {
|
|
47
|
-
expect(isNUP17).toBeDefined()
|
|
48
|
-
|
|
49
|
-
expect(isNUP17('23037001462202165')).toBeTruthy()
|
|
50
|
-
expect(isNUP17('23037001462202165')).toBeTruthy()
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('Deve importar isPIS', () => {
|
|
54
|
-
expect(isPIS).toBeDefined()
|
|
55
|
-
|
|
56
|
-
expect(isPIS('23795126955')).toBeTruthy()
|
|
57
|
-
expect(isPIS('23795126955')).toBeTruthy()
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
test('Deve importar isPostalTrackCode', () => {
|
|
61
|
-
expect(isPostalTrackCode).toBeDefined()
|
|
62
|
-
|
|
63
|
-
expect(isPostalTrackCode('PN718252423BR')).toBeTruthy()
|
|
64
|
-
expect(isPostalTrackCode('PN718252423BR')).toBeTruthy()
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test('Deve importar isRenavam', () => {
|
|
68
|
-
expect(isRenavam).toBeDefined()
|
|
69
|
-
|
|
70
|
-
expect(isRenavam('80499688374')).toBeTruthy()
|
|
71
|
-
expect(isRenavam('80499688374')).toBeTruthy()
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test('Deve importar isTituloEleitor', () => {
|
|
75
|
-
expect(isTituloEleitor).toBeDefined()
|
|
76
|
-
|
|
77
|
-
expect(isTituloEleitor('153036161686')).toBeTruthy()
|
|
78
|
-
expect(isTituloEleitor('153036161686')).toBeTruthy()
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
test('Deve importar isCarPlate', () => {
|
|
82
|
-
expect(isCarPlate).toBeDefined()
|
|
83
|
-
|
|
84
|
-
expect(isCarPlate('AAA-1A34')).toBeTruthy()
|
|
85
|
-
expect(isCarPlate('AAA-1A34')).toBeTruthy()
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test('Deve importar isPhone', () => {
|
|
89
|
-
expect(isPhone).toBeDefined()
|
|
90
|
-
|
|
91
|
-
expect(isPhone('+5584987654321')).toBeTruthy()
|
|
92
|
-
expect(isPhone('+558433311454')).toBeTruthy()
|
|
93
|
-
})
|
|
94
|
-
test('Deve importar isPixKey', () => {
|
|
95
|
-
expect(isPixKey).toBeDefined()
|
|
96
|
-
|
|
97
|
-
expect(isPixKey('klawdyo@gmail.com')).toBeTruthy()
|
|
98
|
-
expect(isPixKey('+5584987654321')).toBeTruthy()
|
|
99
|
-
expect(isPixKey('+558433311454')).toBeTruthy()
|
|
100
|
-
expect(isPixKey('01234567-0123-4567-8900-000000000000')).toBeTruthy()
|
|
101
|
-
expect(isPixKey('99360938000180')).toBeTruthy()
|
|
102
|
-
expect(isPixKey('74172316085')).toBeTruthy()
|
|
103
|
-
})
|
|
104
|
-
test('Deve importar isPixCopyPaste', () => {
|
|
105
|
-
expect(isPixCopyPaste).toBeDefined()
|
|
106
|
-
const pixStone = `00020101021226820014br.gov.bcb.pix2560pix.stone.com.br/pix/v2/b411f5c8-e97f-4a18-af0e-fc66491748d7520400005303986540510.005802BR5925DIOGO DA SILVA SANTOS LTD6014RIO DE JANEIRO622905251e3afd7926983f8ffe086cdc16304FF60`;
|
|
107
|
-
const pixManual = `00020126550014BR.GOV.BCB.PIX0123alexandrepato@gmail.com0206almoco5204000053039865406100.005802BR5914Alexandre Pato6009Ipanguacu61085950800062490511PIXJS76657250300017BR.GOV.BCB.BRCODE01051.0.0630455CF`;
|
|
108
|
-
|
|
109
|
-
expect(isPixCopyPaste(pixStone)).toBeTruthy()
|
|
110
|
-
expect(isPixCopyPaste(pixManual)).toBeTruthy()
|
|
111
|
-
})
|
|
112
|
-
})
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { JudicialProcess } from '../src/judicial-process';
|
|
2
|
-
import { insertAtPosition } from '../src/_helpers/utils';
|
|
3
|
-
|
|
4
|
-
describe('JudicialProcess', () => {
|
|
5
|
-
describe('constructor', () => {
|
|
6
|
-
test.each([
|
|
7
|
-
'6105283-83.2009.8.13.0024',
|
|
8
|
-
'00110060720168200100',
|
|
9
|
-
'08002785520134058400',
|
|
10
|
-
'08002732820164058400',
|
|
11
|
-
])('deve estar definido', (input) => {
|
|
12
|
-
const proc = new JudicialProcess(input)
|
|
13
|
-
expect(proc).toBeDefined();
|
|
14
|
-
expect(proc.processNumber).toBe(input.replace(/\D/g, '').substring(0, 7))
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test.each([
|
|
18
|
-
'0110060720168200100', // caractere a menos
|
|
19
|
-
'61052838320098130023',
|
|
20
|
-
'00110060720168200102',
|
|
21
|
-
'08002785520134058401',
|
|
22
|
-
'08002732820164058406',
|
|
23
|
-
'08002732820160058400', // Órgão judiciário igual a 0
|
|
24
|
-
'', // vazio
|
|
25
|
-
'008002732820160058400', // caracteres a mais
|
|
26
|
-
'8002732820160058400', // caracteres a menos
|
|
27
|
-
null,
|
|
28
|
-
undefined,
|
|
29
|
-
])('deve lançar erro %s', (input) => {
|
|
30
|
-
expect(() => new JudicialProcess(input as any)).toThrow();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe('mask', () => {
|
|
35
|
-
test.each([
|
|
36
|
-
{ num: '00020802520125150049', expected: '0002080-25.2012.5.15.0049' },
|
|
37
|
-
{ num: '61052838320098130024', expected: '6105283-83.2009.8.13.0024' },
|
|
38
|
-
{ num: '00110060720168200100', expected: '0011006-07.2016.8.20.0100' },
|
|
39
|
-
{ num: '08002785520134058400', expected: '0800278-55.2013.4.05.8400' },
|
|
40
|
-
{ num: '08002732820164058400', expected: '0800273-28.2016.4.05.8400' },
|
|
41
|
-
])('mask() - Testando se a máscara foi gerada corretamente', (item) => {
|
|
42
|
-
const masked = new JudicialProcess(item.num).mask();
|
|
43
|
-
|
|
44
|
-
expect(masked).toBe(item.expected);
|
|
45
|
-
expect(masked).toMatch(/^\d{7}-\d{2}.\d{4}.\d.\d{2}.\d{4}$/);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('fake()', () => {
|
|
50
|
-
test.each([...Array(5)])('Deve gerar um fake válido', () => {
|
|
51
|
-
const result = JudicialProcess.fake();
|
|
52
|
-
expect(result).toBeDefined();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test.each([...Array(5)])(
|
|
56
|
-
'Deve gerar um fake válido com o órgão definido',
|
|
57
|
-
() => {
|
|
58
|
-
const result = JudicialProcess.fake({ court: '3' });
|
|
59
|
-
expect(result).toBeDefined();
|
|
60
|
-
expect(result.court).toBe('3');
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
test.each([...Array(5)])(
|
|
65
|
-
'Deve gerar um fake válido com o tribunal definido',
|
|
66
|
-
() => {
|
|
67
|
-
const result = JudicialProcess.fake({ subCourt: '13' });
|
|
68
|
-
expect(result).toBeDefined();
|
|
69
|
-
expect(result.subCourt).toBe('13');
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
test.each([...Array(5)])(
|
|
74
|
-
'Deve gerar um fake válido com o ano definido',
|
|
75
|
-
() => {
|
|
76
|
-
const result = JudicialProcess.fake({ year: '2024' });
|
|
77
|
-
expect(result).toBeDefined();
|
|
78
|
-
expect(result.year).toBe('2024');
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
test.each([...Array(5)])(
|
|
83
|
-
'Deve gerar um fake válido com a unidade de origem definida',
|
|
84
|
-
() => {
|
|
85
|
-
const result = JudicialProcess.fake({ origin: '1313' });
|
|
86
|
-
expect(result).toBeDefined();
|
|
87
|
-
expect(result.origin).toBe('1313');
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
test.each([
|
|
92
|
-
{ court: '0' },
|
|
93
|
-
{ court: '11' },
|
|
94
|
-
{ subCourt: '1' },
|
|
95
|
-
{ subCourt: '00' },
|
|
96
|
-
{ subCourt: '111' },
|
|
97
|
-
{ year: '111' },
|
|
98
|
-
{ year: '11111' },
|
|
99
|
-
{ origin: '0000' },
|
|
100
|
-
{ origin: '111' },
|
|
101
|
-
{ origin: '11111' },
|
|
102
|
-
])(
|
|
103
|
-
'Deve lançar erro quando tenta criar fake com valores pré-definidos inválidos %s',
|
|
104
|
-
(input) => {
|
|
105
|
-
expect(() => JudicialProcess.fake(input)).toThrow();
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('checksum', () => {
|
|
111
|
-
test.each([
|
|
112
|
-
{ num: '000208020125150049', dv: '25' },
|
|
113
|
-
{ num: '610528320098130024', dv: '83' },
|
|
114
|
-
{ num: '001100620168200100', dv: '07' },
|
|
115
|
-
{ num: '080027820134058400', dv: '55' },
|
|
116
|
-
{ num: '080027320164058400', dv: '28' },
|
|
117
|
-
])('dv() - Verificando se o DV gerado está correto', (item) => {
|
|
118
|
-
const calcDv = JudicialProcess.checksum(item.num);
|
|
119
|
-
|
|
120
|
-
expect(calcDv).toBe(item.dv);
|
|
121
|
-
expect(typeof calcDv).toBe('string');
|
|
122
|
-
|
|
123
|
-
// Preenche número do processo com o seu DV
|
|
124
|
-
const full = insertAtPosition(item.num, item.dv, 7)
|
|
125
|
-
expect(new JudicialProcess(full).checksum).toBe(item.dv)
|
|
126
|
-
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
test.each(['0002080201251500499', '00020802012515004', ''])(
|
|
131
|
-
'deve lançar erro de dv',
|
|
132
|
-
(item) => {
|
|
133
|
-
expect(() => JudicialProcess.checksum(item)).toThrow();
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('toString', () => {
|
|
139
|
-
test.each([
|
|
140
|
-
{ input: '6105283-83.2009.8.13.0024', expected: '61052838320098130024', },
|
|
141
|
-
{ input: '00110060720168200100', expected: '00110060720168200100', },
|
|
142
|
-
{ input: '08002785520134058400', expected: '08002785520134058400', },
|
|
143
|
-
{ input: '08002732820164058400', expected: '08002732820164058400', },
|
|
144
|
-
])('deve exibir o valor sem caracteres especiais', (input) => {
|
|
145
|
-
|
|
146
|
-
const proc = new JudicialProcess(input.input)
|
|
147
|
-
|
|
148
|
-
expect(proc.toString()).toBe(input.expected)
|
|
149
|
-
expect(proc.toString()).toHaveLength(20)
|
|
150
|
-
|
|
151
|
-
expect(proc.value).toBe(input.expected)
|
|
152
|
-
expect(proc.value).toHaveLength(20)
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
describe('getWithoutChecksum', () => {
|
|
159
|
-
test('Deve pegar o número completo do processo sem o DV', () => {
|
|
160
|
-
// expect(new JudicialProcess('00020802520125150049').)
|
|
161
|
-
expect(JudicialProcess.getWithoutChecksum('00020802520125150049')).toBe('000208020125150049')
|
|
162
|
-
expect(JudicialProcess.getWithoutChecksum('000208020125150049')).toBe('000208020125150049')
|
|
163
|
-
expect(() => JudicialProcess.getWithoutChecksum('00020802012515004')).toThrow()
|
|
164
|
-
});
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
describe('getFakeSubCourt', () => {
|
|
168
|
-
test('Deve pegar aleatoriamente uma subcorte', () => {
|
|
169
|
-
// se informar zero, use 01
|
|
170
|
-
expect(JudicialProcess.getFakeSubCourt('0')).toBe('01')
|
|
171
|
-
expect(JudicialProcess.getFakeSubCourt('00')).toBe('01')
|
|
172
|
-
// vazio calcula um aleatorio
|
|
173
|
-
expect(JudicialProcess.getFakeSubCourt('').length).toBe(2)
|
|
174
|
-
expect(JudicialProcess.getFakeSubCourt(null as any).length).toBe(2)
|
|
175
|
-
expect(JudicialProcess.getFakeSubCourt(undefined as any).length).toBe(2)
|
|
176
|
-
// se informar um válido, use ele mesmo
|
|
177
|
-
expect(JudicialProcess.getFakeSubCourt('02')).toBe('02')
|
|
178
|
-
// se informar um inválido, use 01
|
|
179
|
-
expect(JudicialProcess.getFakeSubCourt('345')).toBe('01')
|
|
180
|
-
|
|
181
|
-
const fake = JudicialProcess.getFakeSubCourt();
|
|
182
|
-
|
|
183
|
-
expect(fake.length).toBe(2);
|
|
184
|
-
expect(fake >= '01').toBeTruthy();
|
|
185
|
-
expect(fake <= '99').toBeTruthy();
|
|
186
|
-
});
|
|
187
|
-
})
|
|
188
|
-
});
|
package/test/nup17.spec.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { NUP17 } from '../src/nup17';
|
|
2
|
-
|
|
3
|
-
describe('NUP17', () => {
|
|
4
|
-
describe('constructor', () => {
|
|
5
|
-
test.each([
|
|
6
|
-
// Masked
|
|
7
|
-
'23037.001380/2021-11',
|
|
8
|
-
'23037.001434/2021-48',
|
|
9
|
-
'23037.001321/2021-42',
|
|
10
|
-
// String
|
|
11
|
-
'23037001462202165',
|
|
12
|
-
'23037001537202116',
|
|
13
|
-
'23037001086202117',
|
|
14
|
-
])('%s deve ser definido', (input) => {
|
|
15
|
-
expect(new NUP17(input)).toBeDefined();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test.each([
|
|
19
|
-
'23037001380202112',
|
|
20
|
-
'23037001434202142',
|
|
21
|
-
'23037001462202162',
|
|
22
|
-
'23037001537202112',
|
|
23
|
-
'', // vazio
|
|
24
|
-
'023037001537202112', // caracteres a mais
|
|
25
|
-
'3037001537202112', // caracteres a menos
|
|
26
|
-
null,
|
|
27
|
-
undefined,
|
|
28
|
-
])('%s deve lançar erro', (input) => {
|
|
29
|
-
expect(() => new NUP17(input as any)).toThrow();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('mask', () => {
|
|
34
|
-
test.each([
|
|
35
|
-
{ num: '23037001380202111', expected: '23037.001380/2021-11' },
|
|
36
|
-
{ num: '23037001434202148', expected: '23037.001434/2021-48' },
|
|
37
|
-
{ num: '23037001321202142', expected: '23037.001321/2021-42' },
|
|
38
|
-
{ num: '23037001462202165', expected: '23037.001462/2021-65' },
|
|
39
|
-
{ num: '23037001537202116', expected: '23037.001537/2021-16' },
|
|
40
|
-
{ num: '23037001086202117', expected: '23037.001086/2021-17' },
|
|
41
|
-
])('mask() - Testando se a máscara foi gerada corretamente', (item) => {
|
|
42
|
-
const masked = new NUP17(item.num).mask();
|
|
43
|
-
|
|
44
|
-
expect(masked).toBe(item.expected);
|
|
45
|
-
expect(masked).toMatch(/^\d{5}\.\d{6}\/\d{4}-\d{2}$/);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('fake', () => {
|
|
50
|
-
test.each([...Array(5)])('Deve gerar fake válido', () => {
|
|
51
|
-
const result = NUP17.fake();
|
|
52
|
-
expect(result).toBeDefined();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('checksum', () => {
|
|
57
|
-
test.each([
|
|
58
|
-
{ num: '230370013802021', expected: '11' },
|
|
59
|
-
{ num: '230370014342021', expected: '48' },
|
|
60
|
-
{ num: '230370013212021', expected: '42' },
|
|
61
|
-
{ num: '230370014622021', expected: '65' },
|
|
62
|
-
{ num: '230370015372021', expected: '16' },
|
|
63
|
-
{ num: '230370010862021', expected: '17' },
|
|
64
|
-
])('dv() - Verificando se o DV gerado está correto', (item) => {
|
|
65
|
-
const calcDv = NUP17.checksum(item.num);
|
|
66
|
-
|
|
67
|
-
expect(calcDv).toBe(item.expected);
|
|
68
|
-
expect(typeof calcDv).toBe('string');
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
test.each(['23037001462202', '2303700146220211', ''])(
|
|
73
|
-
'deve lançar erro de dv',
|
|
74
|
-
(item) => {
|
|
75
|
-
expect(() => NUP17.checksum(item)).toThrow();
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('toString', () => {
|
|
81
|
-
test.each([
|
|
82
|
-
{ input: '23037001380202111', expected: '23037001380202111' },
|
|
83
|
-
{ input: '23037001434202148', expected: '23037001434202148' },
|
|
84
|
-
{ input: '23037001321202142', expected: '23037001321202142' },
|
|
85
|
-
{ input: '23037.001462/2021-65', expected: '23037001462202165' },
|
|
86
|
-
{ input: '23037.001537/2021-16', expected: '23037001537202116' },
|
|
87
|
-
{ input: '23037.001086/2021-17', expected: '23037001086202117' },
|
|
88
|
-
])('Deve exibir o valor sem o caracteres especiais', (item) => {
|
|
89
|
-
const nup = new NUP17(item.input);
|
|
90
|
-
|
|
91
|
-
expect(nup.toString()).toBe(item.expected);
|
|
92
|
-
expect(nup.toString()).toHaveLength(17);
|
|
93
|
-
|
|
94
|
-
expect(nup.value).toBe(item.expected);
|
|
95
|
-
expect(nup.value).toHaveLength(17);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
});
|
package/test/phone.spec.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Phone } from '../src/phone';
|
|
2
|
-
|
|
3
|
-
const cellPhones = [
|
|
4
|
-
'+5584999873456',
|
|
5
|
-
'+55 84 9 9987 3456',
|
|
6
|
-
'+55 (84) 9 9987-3456',
|
|
7
|
-
'+55 (84) 99987-3456',
|
|
8
|
-
'84 99987-3456',
|
|
9
|
-
];
|
|
10
|
-
const phones = [
|
|
11
|
-
'+558433311454',
|
|
12
|
-
'84 3331-1454',
|
|
13
|
-
'84 3331 1454',
|
|
14
|
-
'(84) 3331 1454',
|
|
15
|
-
'84-3331-1454',
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
describe('Phone', () => {
|
|
19
|
-
describe('constructor', () => {
|
|
20
|
-
test.each(cellPhones)('Celular %s deve estar definido', (value) => {
|
|
21
|
-
const obj = new Phone(value);
|
|
22
|
-
expect(obj.value).toBe('+5584999873456');
|
|
23
|
-
expect(obj.ddi).toBe('+55');
|
|
24
|
-
expect(obj.ddd).toBe('84');
|
|
25
|
-
expect(obj.phone).toBe('999873456');
|
|
26
|
-
expect(obj.isMobile).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test.each(phones)('Telefone fixo %s deve estar definido', (value) => {
|
|
30
|
-
const obj = new Phone(value);
|
|
31
|
-
expect(obj.value).toBe('+558433311454');
|
|
32
|
-
expect(obj.ddi).toBe('+55');
|
|
33
|
-
expect(obj.ddd).toBe('84');
|
|
34
|
-
expect(obj.phone).toBe('33311454');
|
|
35
|
-
expect(obj.isMobile).toBeFalsy;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test.each(['12', '1234567890000', '00999870222'])('Deve lançar exceção', (value) => {
|
|
39
|
-
expect(() => new Phone(value)).toThrow();
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('fake', () => {
|
|
44
|
-
test.each([...Array(5)])('Cria um fake', () => {
|
|
45
|
-
const fake = Phone.fake();
|
|
46
|
-
expect(fake).toBeDefined();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test.each([...Array(50)])('Cria um fake com DDD 11', () => {
|
|
50
|
-
const fake = Phone.fake({ ddd: '11' });
|
|
51
|
-
expect(fake).toBeDefined();
|
|
52
|
-
expect(fake.ddd).toBe('11');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('Cria um fake com DDD inválido', () => {
|
|
56
|
-
expect(() => Phone.fake({ ddd: '10' })).toThrow();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test.each([...Array(5)])('Cria um fake com isMobile=true', () => {
|
|
60
|
-
const fake = Phone.fake({ isMobile: true });
|
|
61
|
-
expect(fake).toBeDefined();
|
|
62
|
-
expect(fake.isMobile).toBeTruthy();
|
|
63
|
-
expect(fake.phone.length).toBe(9);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test.each([...Array(5)])('Cria um fake com isLandline=true', () => {
|
|
67
|
-
const fake = Phone.fake({ isLandline: true });
|
|
68
|
-
expect(fake).toBeDefined();
|
|
69
|
-
expect(fake.isMobile).toBeFalsy();
|
|
70
|
-
expect(fake.phone.length).toBe(8);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe('mask', () => {
|
|
75
|
-
test.each(cellPhones)('Máscara de celular sem país', (input) => {
|
|
76
|
-
const phone = new Phone(input);
|
|
77
|
-
expect(phone.mask({ withCountry: false })).toBe('84 999873456');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test.each(cellPhones)('Máscara de celular com país', (input) => {
|
|
81
|
-
const phone = new Phone(input);
|
|
82
|
-
expect(phone.mask({ withCountry: true })).toBe('+55 84 999873456');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test.each(phones)('Máscara de telefone fixo sem país', (input) => {
|
|
86
|
-
const phone = new Phone(input);
|
|
87
|
-
expect(phone.mask({ withCountry: false })).toBe('84 33311454');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test.each(phones)('Máscara de telefone fixo com país', (input) => {
|
|
91
|
-
const phone = new Phone(input);
|
|
92
|
-
expect(phone.mask({ withCountry: true })).toBe('+55 84 33311454');
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
describe('checksum', () => {
|
|
97
|
-
expect(() => Phone.checksum()).toThrow()
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
describe('toString', () => {
|
|
101
|
-
test.each([...phones, ...cellPhones])('Deve exibir o valor sem o caracteres especiais', (input) => {
|
|
102
|
-
const phone = new Phone(input);
|
|
103
|
-
const cleared = phone.value.replace(/[()\s-]+/g, '');
|
|
104
|
-
|
|
105
|
-
expect(phone.toString()).toBe(cleared)
|
|
106
|
-
expect(phone.toString()).toHaveLength(cleared.length)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
expect(phone.value).toBe(cleared)
|
|
110
|
-
expect(phone.value).toHaveLength(cleared.length)
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
package/test/pis-pasep.spec.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { PIS } from '../src/pis-pasep';
|
|
2
|
-
|
|
3
|
-
describe('PIS', () => {
|
|
4
|
-
describe('constructor', () => {
|
|
5
|
-
test.each([
|
|
6
|
-
'71282677380',
|
|
7
|
-
'23795126955',
|
|
8
|
-
'50012973803',
|
|
9
|
-
'27890141144',
|
|
10
|
-
'268.27649.96-0',
|
|
11
|
-
'613.01862.91-7',
|
|
12
|
-
])('deve estar definido', (input) => {
|
|
13
|
-
expect(new PIS(input)).toBeDefined();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test.each([
|
|
17
|
-
'712.82677.38-2',
|
|
18
|
-
'237.95126.95-4',
|
|
19
|
-
'500.12973.80-1',
|
|
20
|
-
'278.90141.14-9',
|
|
21
|
-
'268.27649.96-2',
|
|
22
|
-
'613.01862.91-4',
|
|
23
|
-
'111.11111.11-1',
|
|
24
|
-
'', // vazio
|
|
25
|
-
'0613.01862.91-4', // caracteres a mais
|
|
26
|
-
'13.01862.91-4', // caracteres a menos
|
|
27
|
-
null,
|
|
28
|
-
undefined,
|
|
29
|
-
])('deve lançar erro', (input) => {
|
|
30
|
-
expect(() => new PIS(input as any)).toThrow();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe('mask', () => {
|
|
35
|
-
test.each([
|
|
36
|
-
{ num: '71282677380', expected: '712.82677.38-0' },
|
|
37
|
-
{ num: '23795126955', expected: '237.95126.95-5' },
|
|
38
|
-
{ num: '50012973803', expected: '500.12973.80-3' },
|
|
39
|
-
])('mask() - Testando se a máscara foi gerada corretamente', (item) => {
|
|
40
|
-
const masked = new PIS(item.num).mask();
|
|
41
|
-
|
|
42
|
-
expect(masked).toBe(item.expected);
|
|
43
|
-
expect(masked).toMatch(/^\d{3}.\d{5}.\d{2}-\d{1}$/);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('fake', () => {
|
|
48
|
-
test.each([...Array(5)])('deve gerar um fake válido', () => {
|
|
49
|
-
const result = PIS.fake();
|
|
50
|
-
expect(result).toBeDefined();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('checksum', () => {
|
|
55
|
-
test.each([
|
|
56
|
-
{ num: '7128267738', expected: '0' },
|
|
57
|
-
{ num: '2379512695', expected: '5' },
|
|
58
|
-
{ num: '5001297380', expected: '3' },
|
|
59
|
-
])('%s deve gerar dv correto', (item) => {
|
|
60
|
-
const calcDv = PIS.checksum(item.num);
|
|
61
|
-
|
|
62
|
-
expect(calcDv).toBe(item.expected);
|
|
63
|
-
expect(typeof calcDv).toBe('string');
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test.each(['712826778', '71282677381', ''])(
|
|
67
|
-
'%s deve lançar erro de dv',
|
|
68
|
-
(item) => {
|
|
69
|
-
expect(() => PIS.checksum(item)).toThrow();
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe('toString', () => {
|
|
75
|
-
test.each([
|
|
76
|
-
{ input: '71282677380', expected: '71282677380', },
|
|
77
|
-
{ input: '23795126955', expected: '23795126955', },
|
|
78
|
-
{ input: '50012973803', expected: '50012973803', },
|
|
79
|
-
{ input: '27890141144', expected: '27890141144', },
|
|
80
|
-
{ input: '268.27649.96-0', expected: '26827649960', },
|
|
81
|
-
{ input: '613.01862.91-7', expected: '61301862917', },
|
|
82
|
-
])('Deve exibir o valor sem o caracteres especiais', (item) => {
|
|
83
|
-
const pis = new PIS(item.input);
|
|
84
|
-
|
|
85
|
-
expect(pis.toString()).toBe(item.expected);
|
|
86
|
-
expect(pis.toString()).toHaveLength(11);
|
|
87
|
-
|
|
88
|
-
expect(pis.value).toBe(item.expected);
|
|
89
|
-
expect(pis.value).toHaveLength(11);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// pix usado pelo 10 pila.
|
|
2
|
-
|
|
3
|
-
import { PixCopyPaste, PixPart } from '../src/pix-copy-paste';
|
|
4
|
-
|
|
5
|
-
// esse pix é um pix automatico
|
|
6
|
-
const pixStone = `00020101021226820014br.gov.bcb.pix2560pix.stone.com.br/pix/v2/b411f5c8-e97f-4a18-af0e-fc66491748d7520400005303986540510.005802BR5925DIOGO DA SILVA SANTOS LTD6014RIO DE JANEIRO622905251e3afd7926983f8ffe086cdc16304FF60`;
|
|
7
|
-
const pixManual = `00020126550014BR.GOV.BCB.PIX0123alexandrepato@gmail.com0206almoco5204000053039865406100.005802BR5914Alexandre Pato6009Ipanguacu61085950800062490511PIXJS76657250300017BR.GOV.BCB.BRCODE01051.0.0630455CF`;
|
|
8
|
-
|
|
9
|
-
const cases = [
|
|
10
|
-
pixStone,
|
|
11
|
-
pixManual
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
describe('PixCopyPaste', () => {
|
|
16
|
-
describe('constructor', () => {
|
|
17
|
-
test.each(cases)('deve estar definido', (input) => {
|
|
18
|
-
const pix = new PixCopyPaste(input);
|
|
19
|
-
expect(pix).toBeDefined();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('deve lançar um erro ao injetar um caractere na terceira posição', () => {
|
|
23
|
-
const copyPaste = pixStone.slice(0, 4) + 'D' + pixStone.slice(4);
|
|
24
|
-
expect(() => new PixCopyPaste(copyPaste)).toThrow()
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('PixPart', () => {
|
|
29
|
-
describe('parse', () => {
|
|
30
|
-
test.each(cases)('testa o parse', (input) => {
|
|
31
|
-
const parse = PixPart.parse(input);
|
|
32
|
-
|
|
33
|
-
expect(parse).toBeDefined();
|
|
34
|
-
expect(Array.isArray(parse)).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
describe('getPart', () => {
|
|
39
|
-
test.each([
|
|
40
|
-
'', // vazio
|
|
41
|
-
'123', // menos de 3 números
|
|
42
|
-
'acvs', // não começa com 4 números
|
|
43
|
-
|
|
44
|
-
])('deve retornar um valor padrão', (part) => {
|
|
45
|
-
const expected = { part, code: '', size: 0, value: '', rest: part, children: [] }
|
|
46
|
-
expect(PixPart.getPart(part)).toMatchObject(expected);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test.each([
|
|
50
|
-
'0002a', // a partir do quinto valor não tem o mesmo tamanho definido nas posições 3 e 4
|
|
51
|
-
])('deve retornar um erro', (part) => {
|
|
52
|
-
expect(() => PixPart.getPart(part)).toThrow();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|