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 EE = require('../ncas/ee'); const eeScraper = new EE(); const failure = { 'fail':true }; const empty = {}; test.test('Entity', async t => { test.test('EE:: Process PS Entity 001', async t => { const htmlFile = 'tests/data/ee/ent_001.html'; // https://www.fi.ee/en/payment-services/payment-institutions/licensed-payment-institutions-estonia/aktsiaselts-talveaed t.test('EE::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_001_detail.json'); const output = await eeScraper.extractEntityDetails(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('EE::Extract entity license', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_001_licenses.json'); const output = await eeScraper.extractEntityLicense(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity license from Page'); t.end(); }); t.test('EE::Extract Cross Border blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_001_cb.json'); const output = await eeScraper.extractEntityCrossBorder(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('EE::Extract Service blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await eeScraper.extractEntityServices(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity services from Page'); t.end(); }); t.test('EE::Extract Branch blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await eeScraper.extractEntityBranches(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity branches from Page'); t.end(); }); t.end(); }); test.test('EE:: Process PS Entity 002', async t => { const htmlFile = 'tests/data/ee/ent_002.html'; // https://www.fi.ee/en/payment-services/payment-institutions/payment-services/providers-cross-border-payment-sevices/2checkout-uk-limited t.test('EE::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_002_detail.json'); const output = await eeScraper.extractEntityDetails(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('EE::Extract entity license', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await eeScraper.extractEntityLicense(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity license from Page'); t.end(); }); t.test('EE::Extract Cross Border blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await eeScraper.extractEntityCrossBorder(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('EE::Extract Service blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_002_services.json'); const output = await eeScraper.extractEntityServices(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity services from Page'); t.end(); }); t.test('EE::Extract Branch blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await eeScraper.extractEntityBranches(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity branches from Page'); t.end(); }); t.end(); }); test.test('EE:: Process EM Entity 003', async t => { const htmlFile = 'tests/data/ee/ent_003.html'; // https://www.fi.ee/en/payment-services/e-money-institutions/providers-cross-border-e-money-services/easy-payment-services-ood t.test('EE::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_003_detail.json'); const output = await eeScraper.extractEntityDetails(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('EE::Extract entity license', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await eeScraper.extractEntityLicense(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity license from Page'); t.end(); }); t.test('EE::Extract Cross Border blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await eeScraper.extractEntityCrossBorder(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('EE::Extract Service blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_003_services.json'); const output = await eeScraper.extractEntityServices(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity services from Page'); t.end(); }); t.test('EE::Extract Branch blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = empty; const output = await eeScraper.extractEntityBranches(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity branches from Page'); t.end(); }); t.end(); }); test.test('EE:: Process CI Entity 004', async t => { const htmlFile = 'tests/data/ee/ent_004.html'; // https://www.fi.ee/en/banking-and-credit/banking-and-credit/credit-institutions/licensed-credit-institutions-estonia/inbank t.test('EE::Extract entity details', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_004_detail.json'); const output = await eeScraper.extractEntityDetails(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('EE::Extract entity license', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_004_licenses.json'); const output = await eeScraper.extractEntityLicense(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity license from Page'); t.end(); }); t.test('EE::Extract Cross Border blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_004_cb.json'); const output = await eeScraper.extractEntityCrossBorder(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity details from Page'); t.end(); }); t.test('EE::Extract Service blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_004_services.json'); const output = await eeScraper.extractEntityServices(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity services from Page'); t.end(); }); t.test('EE::Extract Branch blocks', async t => { const psDetail = fs.readFileSync(htmlFile); const expectedJSON = jsonfile.readFileSync('tests/data/ee/ent_004_branches.json'); const output = await eeScraper.extractEntityBranches(psDetail); t.deepEquals(output, expectedJSON, 'Extracted entity branches from Page'); t.end(); }); t.end(); }); t.end(); });