80 lines
2.3 KiB
JavaScript
80 lines
2.3 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 Malta = require('../ncas/mt');
|
|
|
|
// const failure = { 'fail':true };
|
|
|
|
test('MALTA:: Scrape a Credit Instititute', async t => {
|
|
t.test('Malta::Extract Details from Page 1', async t => {
|
|
const psDetail = fs.readFileSync('tests/data/mt/3504.html');
|
|
const expectedJSON = jsonfile.readFileSync('tests/data/mt/3504-detail.json');
|
|
|
|
const mtScraper = new Malta();
|
|
|
|
const output = await mtScraper.extractEntityV2(psDetail);
|
|
|
|
t.deepEquals(output, expectedJSON, 'Extracted Details from Page');
|
|
|
|
t.end();
|
|
});
|
|
|
|
t.test('Malta::Extract Details from Page 2', async t => {
|
|
const psDetail = fs.readFileSync('tests/data/mt/4570.html');
|
|
const expectedJSON = jsonfile.readFileSync('tests/data/mt/4570.json');
|
|
|
|
const mtScraper = new Malta();
|
|
|
|
const output = await mtScraper.extractEntityV2(psDetail);
|
|
|
|
t.deepEquals(output, expectedJSON, 'Extracted Details from Page');
|
|
|
|
t.end();
|
|
});
|
|
|
|
t.test('Malta::Extract Details from Page 3', async t => {
|
|
const psDetail = fs.readFileSync('tests/data/mt/4257.html');
|
|
const expectedJSON = jsonfile.readFileSync('tests/data/mt/4257.json');
|
|
|
|
const mtScraper = new Malta();
|
|
|
|
const output = await mtScraper.extractEntityV2(psDetail);
|
|
|
|
t.deepEquals(output, expectedJSON, 'Extracted Details from Page');
|
|
|
|
t.end();
|
|
});
|
|
|
|
t.test('Malta::Extract Details with bullet points', async t => {
|
|
const psDetail = fs.readFileSync('tests/data/mt/5266.html');
|
|
const expectedJSON = jsonfile.readFileSync('tests/data/mt/5266.json');
|
|
|
|
const mtScraper = new Malta();
|
|
|
|
const output = await mtScraper.extractEntityV2(psDetail);
|
|
|
|
t.deepEquals(output, expectedJSON, 'Extracted Details with bullet points Page');
|
|
|
|
t.end();
|
|
});
|
|
|
|
t.test('Malta::Extract Details fom a posibly broken page', async t => {
|
|
const psDetail = fs.readFileSync('tests/data/mt/10388.html');
|
|
const expectedJSON = jsonfile.readFileSync('tests/data/mt/10388.json');
|
|
|
|
const mtScraper = new Malta();
|
|
|
|
const output = await mtScraper.extractEntityV2(psDetail);
|
|
|
|
t.deepEquals(output, expectedJSON, 'Extracted Details with bullet points Page');
|
|
|
|
t.end();
|
|
});
|
|
|
|
t.end();
|
|
});
|