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.
36 lines
794 B
JavaScript
36 lines
794 B
JavaScript
import assert from 'assert';
|
|
import cheerio from 'cheerio';
|
|
|
|
import scoreByParents from './score-by-parents';
|
|
|
|
describe('scoreByParents($link)', () => {
|
|
it('returns 25 if parent sig looks like a page', () => {
|
|
const html = `
|
|
<div>
|
|
<div class="next-page">
|
|
<a href="blah">Next page</a>
|
|
</div>
|
|
</div>
|
|
`;
|
|
const $ = cheerio.load(html);
|
|
const $link = $('a').first();
|
|
|
|
assert.equal(scoreByParents($link), 25);
|
|
});
|
|
|
|
it('returns -25 if parent sig looks like a comment', () => {
|
|
const html = `
|
|
<div>
|
|
<div class="comment">
|
|
<a href="blah">Next page</a>
|
|
</div>
|
|
</div>
|
|
`;
|
|
const $ = cheerio.load(html);
|
|
const $link = $('a').first();
|
|
|
|
assert.equal(scoreByParents($link), -25);
|
|
});
|
|
});
|
|
|