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/scoring/add-to-parent.test.js

24 lines
550 B
JavaScript

import assert from 'assert';
import cheerio from 'cheerio';
import {
addToParent,
getScore,
} from './index';
describe('Scoring utils', () => {
describe('addToParent(node, $, amount)', () => {
it('adds 1/4 of a node\'s score it its parent', () => {
const html = '<div score="25"><p score="40">Foo</p></div>';
const $ = cheerio.load(html);
let $node = $('p').first();
$node = addToParent($node, $, 40);
assert.equal(getScore($node.parent()), 35);
assert.equal(getScore($node), 40);
});
});
});