37 lines
1020 B
JavaScript
37 lines
1020 B
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 { reduceArticle, reduceArticleV2 } = require('../server/reducers/euronews');
|
|
|
|
const psDetail = fs.readFileSync('test/data/euronews/20200506-widgets.html');
|
|
|
|
test('Euronews', async t => {
|
|
t.test('Reduce a page', async t => {
|
|
const expectedJSON = { 'bob':false }; // jsonfile.readFileSync('tests/data/cz/ps001.json');
|
|
|
|
const output = await reduceArticle(psDetail);
|
|
|
|
t.deepEquals(output, expectedJSON, 'Extracted Details from Page');
|
|
|
|
t.end();
|
|
});
|
|
|
|
t.test('Reduce a page V2', async t => {
|
|
const expectedJSON = { 'bob':false }; // jsonfile.readFileSync('tests/data/cz/ps001.json');
|
|
|
|
const output = await reduceArticleV2(psDetail);
|
|
|
|
t.deepEquals(output, expectedJSON, 'Extracted Details from Page');
|
|
|
|
t.end();
|
|
});
|
|
|
|
t.end();
|
|
});
|