-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
59 lines (55 loc) · 1.89 KB
/
test.js
File metadata and controls
59 lines (55 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
const ava = require('ava');
const bir = require('.');
const test_nip_entity = {
5262596640: {
city: 'Warszawa',
community: 'm. st. Warszawa',
county: 'Mokotów',
flat_no: '',
house_no: '21',
name: 'GŁÓWNY INSPEKTORAT TRANSPORTU DROGOWEGO',
nip: '5262596640',
postal_code: '02-676',
regon: '017427604',
regon14: '017427604',
regon9: '017427604',
street: 'ul. Test-Krucza',
teryt: '0918130',
voivodeship: 'MAZOWIECKIE',
},
6911051353: {
name: 'Przychodnia Stomatologiczna "VITADENT" Niepubliczny Zakład Opieki Zdrowotnej Jerzy XXXXXXXX',
nip: '6911051353',
regon14: '390151863',
regon9: '390151863',
regon: '390151863',
postal_code: '59-220',
city: 'Legnica',
voivodeship: 'DOLNOŚLĄSKIE',
community: 'm. Legnica',
county: 'M. Legnica',
street: 'ul. Test-Wilcza',
house_no: '9',
flat_no: '1',
teryt: '0954047',
},
};
Object.entries(test_nip_entity).forEach(([nip, expect]) => {
// BIR reject login twice at the same time.
ava.serial(`Test NIP handling ${expect.name} (${nip})`, async t => {
const client = bir(process.env.GUS_ENV === 'production');
await client.login(process.env.GUS_API_KEY || 'abcde12345abcde12345');
const entity = await client.search_nip(nip);
const report = await client.report(entity.regon14, entity.full_report);
t.deepEqual(report, expect);
});
});
ava.serial('Throws on invalid value', async t => {
const client = bir(process.env.GUS_ENV === 'production');
await client.login(process.env.GUS_API_KEY || 'abcde12345abcde12345');
await t.throwsAsync(client.report('234'), {
code: '4',
message: 'Nie znaleziono podmiotu dla podanych kryteriów wyszukiwania.',
});
});