obdfcascrape/tests/scrape.sk.js
Martin Donnelly be5d3eae07 init
2019-05-05 20:13:56 +01:00

124 lines
3.8 KiB
JavaScript

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 cheerio = require('cheerio');
const path = require('path');
const Slovakia = require('../ncas/sk');
const sourcePath = path.join(__dirname, 'data/sk/');
const skScraper = new Slovakia();
test.test('SLOVAKIA:: Scrape a Payment Service 001', async t => {
t.test('SLOVAKIA::Extract Payment Services Basic Details from Page', async t => {
const psDetail = fs.readFileSync('tests/data/sk/pi_top_detail_001.html');
const expectedJSON = jsonfile.readFileSync('tests/data/sk/pi_top_detail_001.json');
const $ = cheerio.load(psDetail);
const output = await skScraper.processEntityDetailBasicDetails($);
t.deepEquals(output, expectedJSON, 'Extracted Basic Details from Page');
t.end();
});
t.test('SLOVAKIA::Extract Payment Services Table from Page', async t => {
const psDetail = fs.readFileSync('tests/data/sk/pi_payment_detail_001.html');
const expectedJSON = jsonfile.readFileSync('tests/data/sk/pi_payment_detail_001.json');
const $ = cheerio.load(psDetail);
const output = await skScraper.processEntityDetailTableV2($);
t.deepEquals(output, expectedJSON, 'Extracted Table Details from Page');
t.end();
});
t.end();
});
test.test('SLOVAKIA:: Scrape a Payment Service 002', async t => {
t.test('SLOVAKIA::Extract Payment Services Basic Details from Page', async t => {
const psDetail = fs.readFileSync('tests/data/sk/pi_top_detail_002.html');
const expectedJSON = jsonfile.readFileSync('tests/data/sk/pi_top_detail_002.json');
const $ = cheerio.load(psDetail);
const output = await skScraper.processEntityDetailBasicDetails($);
t.deepEquals(output, expectedJSON, 'Extracted Basic Details from Page');
t.end();
});
t.test('SLOVAKIA::Extract Payment Services Table from Page', async t => {
const psDetail = fs.readFileSync('tests/data/sk/pi_payment_detail_002.html');
const expectedJSON = jsonfile.readFileSync('tests/data/sk/pi_payment_detail_002.json');
const $ = cheerio.load(psDetail);
const output = await skScraper.processEntityDetailTableV2($);
t.deepEquals(output, expectedJSON, 'Extracted Table Details from Page');
t.end();
});
t.end();
});
test.test('SLOVAKIA:: Scrape a Payment Service 003', async t => {
t.test('SLOVAKIA::Extract Payment Services Basic Details from Page', async t => {
const psDetail = fs.readFileSync('tests/data/sk/pi_top_detail_003.html');
const expectedJSON = jsonfile.readFileSync('tests/data/sk/pi_top_detail_003.json');
const $ = cheerio.load(psDetail);
const output = await skScraper.processEntityDetailBasicDetails($);
t.deepEquals(output, expectedJSON, 'Extracted Basic Details from Page');
t.end();
});
t.test('SLOVAKIA::Extract Payment Services Table from Page', async t => {
const psDetail = fs.readFileSync('tests/data/sk/pi_payment_detail_003.html');
const expectedJSON = jsonfile.readFileSync('tests/data/sk/pi_payment_detail_003.json');
const $ = cheerio.load(psDetail);
const output = await skScraper.processEntityDetailTableV2($);
t.deepEquals(output, expectedJSON, 'Extracted Table Details from Page');
t.end();
});
t.end();
});
test.test('SLOVAKIA:: Scrape a CI ', async t => {
t.test('SLOVAKIA::Complex CI Data', async t => {
const psDetail = fs.readFileSync('tests/data/sk/ci_detail_001.html');
const expectedJSON = jsonfile.readFileSync('tests/data/sk/ci_detail_001.json');
const $ = cheerio.load(psDetail);
const output = await skScraper.processEntityDetailTableV2($);
t.deepEquals(output, expectedJSON, 'Extracted Table Details from Page');
t.end();
});
t.end();
});