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/utils/dom/strip-junk-tags.test.js

24 lines
657 B
JavaScript

import cheerio from 'cheerio';
import assert from 'assert';
import { assertClean } from 'test-helpers';
import HTML from './fixtures/html';
import { stripJunkTags } from './index';
describe('stripJunkTags($)', () => {
it('strips script and other junk tags', () => {
const $ = cheerio.load(HTML.stripsJunk.before);
const result = stripJunkTags($('*').first(), $);
assertClean(result.html(), HTML.stripsJunk.after);
});
it('keeps youtube embeds', () => {
let $ = cheerio.load(HTML.ignoresKeepable.before);
$ = stripJunkTags($('*').first(), $);
assert.equal($('iframe[src^="https://www.youtube.com"]').length, 1);
});
});