lot/test/scrape.js
2019-02-08 14:54:18 +00:00

45 lines
1.0 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 { scrapeResults, scrapeArchive, scrapeSingle } = require('../libs/scraper');
const { retrieveNew } = require('../libs/retriever');
const failure = { 'fail':true };
const empty = {};
test.skip('Scrape page', async t => {
const page = fs.readFileSync('test/data/draw.html');
const expectedJSON = [ '2019-01-29', 14, 24, 26, 32, 39, 3, 8 ];
const output = scrapeResults(page);
t.deepEquals(output, expectedJSON, 'Extracted results');
t.end();
});
test.skip('Scrape Archive 2019', async t => {
const page = fs.readFileSync('test/data/2019.html');
const expectedJSON = failure;
const output = scrapeArchive(page);
console.log(JSON.stringify(output));
t.deepEquals(output, expectedJSON, 'Extracted results');
t.end();
});
test.test('Scrape Latest', async t => {
const m = retrieveNew();
console.log('xxx');
t.end();
});