DefinitelyTyped/types/mozilla-readability/mozilla-readability-tests.ts
ExE Boss 7675b526b5
feat(jsdom): Update to v16.1 (#42200)
* feat(jsdom): Update to v16.1

* test(mozilla‑readability): Remove test dependency on JSDOM

* fix(jsdom): Fix lint errors

* feat(jsdom): Update dependency parse5 to v5
2020-02-14 09:28:24 -08:00

35 lines
985 B
TypeScript

import Readability = require('mozilla-readability');
declare class JSDOM {
constructor(html?: string);
readonly window: Window;
}
// Compiling requires `--noImplicitUseStrict`
// because issue https://github.com/mozilla/readability/issues/346
// requires global variable `Node` when using nodejs.
function test_basic_usage() {
const dom = new JSDOM(`<p>Hello</p><p><strong>Hi!</strong>`);
const reader = new Readability(dom.window.document);
const article = reader.parse();
}
function test_readability_with_options() {
const dom = new JSDOM(`<p>Hello</p><p><strong>Hi!</strong>`);
const options: Readability.Options = {
debug: true,
maxElemsToParse: 100,
};
const article = new Readability(dom.window.document, options).parse();
}
function test_is_probably_readerable() {
const dom = new JSDOM(`<p>Hello</p><p><strong>Hi!</strong>`);
const isReadable = new Readability(dom.window.document).isProbablyReaderable();
}