You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mercury-parser/src/extractors/generic/content/extract-best-node.test.js

27 lines
665 B
JavaScript

import assert from 'assert';
import cheerio from 'cheerio';
import fs from 'fs';
// import HTML from './fixtures/html'
import extractBestNode from './extract-best-node';
describe('extractBestNode($, flags)', () => {
it('scores the dom nodes and returns the best option', () => {
const html = fs.readFileSync('./fixtures/latimes.html', 'utf-8');
const opts = {
stripUnlikelyCandidates: true,
weightNodes: true,
};
const $ = cheerio.load(html);
const bestNode = extractBestNode($, opts);
assert(typeof bestNode, 'object');
// console.log(bestNode.html())
// assert.equal($(bestNode).text().length, 3652)
});
});