const tape = require('tape'); const _test = require('tape-promise').default; // <---- notice 'default' const test = _test(tape); // decorate tape const fs = require('fs'); const jsonfile = require('jsonfile'); const Poland = require('../ncas/pl'); const plScraper = new Poland(); const failure = { 'fail':true }; const empty = {}; test.test('Payment Services', async t => { test.test('POLAND:: Process PS Entity 001', async t => { const htmlFile = 'tests/data/pl/pi_001.html'; t.test('🇵🇱::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); console.log(psDetail); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_001_detail.json'); const output = await plScraper.extractEntityDetails(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('🇵🇱::Extract entity services', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_001_services.json'); const output = await plScraper.extractEntityServices(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity services from Page'); t.end(); }); t.test('🇵🇱::Extract entity Agents', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await plScraper.extractEntityAgents(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity agents from Page'); t.equals(output.length, 0, 'Extracted 0 entity agents from Page'); t.end(); }); t.test('🇵🇱::Extract entity Branches', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await plScraper.extractEntityBranches(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity branches from Page'); t.equals(output.length, 0, 'Extracted 0 entity branches from Page'); t.end(); }); t.test('🇵🇱::Extract entity Activities', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await plScraper.extractEntityActivity(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity activities from Page'); t.end(); }); t.end(); }); test.test('POLAND:: Process PS Entity 002', async t => { const htmlFile = 'tests/data/pl/pi_002.html'; t.test('🇵🇱::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_002_detail.json'); const output = await plScraper.extractEntityDetails(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('🇵🇱::Extract entity services', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_002_services.json'); const output = await plScraper.extractEntityServices(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity services from Page'); t.end(); }); t.test('🇵🇱::Extract entity Agents', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_002_agents.json'); const output = await plScraper.extractEntityAgents(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity agents from Page'); t.equals(output.length, 5, 'Extracted 5 entity agents from Page'); t.end(); }); t.test('🇵🇱::Extract entity Branches', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_002_branches.json'); const output = await plScraper.extractEntityBranches(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity branches from Page'); t.equals(output.length, 1, 'Extracted 1 entity branches from Page'); t.end(); }); t.test('🇵🇱::Extract entity Activities', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await plScraper.extractEntityActivity(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity activities from Page'); t.end(); }); t.end(); }); test.test('POLAND:: Process PS Entity 003', async t => { const htmlFile = 'tests/data/pl/pi_003.html'; t.test('🇵🇱::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_003_detail.json'); const output = await plScraper.extractEntityDetails(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('🇵🇱::Extract entity services', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_003_services.json'); const output = await plScraper.extractEntityServices(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity services from Page'); t.end(); }); t.test('🇵🇱::Extract entity Agents', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await plScraper.extractEntityAgents(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity agents from Page'); t.equals(output.length, 0, 'Extracted 0 entity agents from Page'); t.end(); }); t.test('🇵🇱::Extract entity Branches', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await plScraper.extractEntityBranches(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity branches from Page'); t.equals(output.length, 0, 'Extracted 0 entity branches from Page'); t.end(); }); t.test('🇵🇱::Extract entity Activities', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/pi_003_activity.json'); const output = await plScraper.extractEntityActivity(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity activities from Page'); t.end(); }); t.end(); }); t.end(); }); test.test('Credit Services', async t => { test.test('POLAND:: Process CS Entity 001', async t => { const htmlFile = 'tests/data/pl/cs_001.html'; t.test('🇵🇱::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = 'AXA UBEZPIECZENIA TUiR S.A.'; const output = await plScraper.extractCSHeading(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity heading from Page'); t.end(); }); t.test('🇵🇱::Extract entity body text', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = 'Nazwa zestawienia: Zestawienie notyfikacji dotyczących działalności krajowych zakładów ubezpieczeń świadczące usługi w formie innej niż oddział w państwach UE/EEA'; const output = await plScraper.extractCSBodyText(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity body text from Page'); t.end(); }); t.test('🇵🇱::Extract entity table', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/cs_001_table.json'); const output = await plScraper.extractCSTable(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity table from Page'); t.end(); }); t.end(); }); test.test('POLAND:: Process CS Entity 002', async t => { const htmlFile = 'tests/data/pl/cs_002.html'; t.test('🇵🇱::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = 'HSBC Bank Polska S.A.'; const output = await plScraper.extractCSHeading(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity heading from Page'); t.end(); }); t.test('🇵🇱::Extract entity body text', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = 'Nazwa zestawienia: Zestawienie notyfikacji dotyczących działalności transgranicznej banków krajowych na terytoriach państw należących do EOG'; const output = await plScraper.extractCSBodyText(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity body text from Page'); t.end(); }); t.test('🇵🇱::Extract entity table', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/cs_002_table.json'); const output = await plScraper.extractCSTable(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity table from Page'); t.end(); }); t.end(); }); test.test('POLAND:: Process Art 70', async t => { const htmlFile = 'tests/data/pl/cs_art70.html'; t.test('🇵🇱::Extract Art 70 details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/pl/cs_art70.json'); const output = await plScraper.reduceArt70(psDetail); t.deepEquals(output, expectedJSON, 'Extracted Art70 data from Page'); t.end(); }); t.end(); }); t.end(); });