diff --git a/jsdom/jsdom-tests.ts b/jsdom/jsdom-tests.ts
index 87eddbfc5..cb6992b49 100644
--- a/jsdom/jsdom-tests.ts
+++ b/jsdom/jsdom-tests.ts
@@ -1,17 +1,17 @@
import jsdom = require("jsdom");
+jsdom.defaultDocumentFeatures.FetchExternalResources = ["img"];
+
jsdom.env(
"http://nodejs.org/dist/",
["http://code.jquery.com/jquery.js"],
- function (errors, window) {
- console.log("there have been nodejs releases!");
+ function (errors: Error[], window: Window) {
}
);
jsdom.env(
"http://nodejs.org/dist/",
- function (errors, window) {
- console.log("there have been nodejs releases!");
+ function (errors: Error[], window: Window) {
}
);
@@ -20,28 +20,21 @@ jsdom.env(
{
scripts: ["http://code.jquery.com/jquery.js"],
},
- function (errors, window) {
- console.log("there have been nodejs releases!");
+ function (errors: Error[], window: Window) {
}
);
jsdom.env(
'
jsdom!
',
["http://code.jquery.com/jquery.js"],
- function (errors, window) {
- console.log("contents of a.the-link:", (window).$("a.the-link").text());
+ function (errors: Error[], window: Window) {
}
);
jsdom.env({
url: "http://news.ycombinator.com/",
scripts: ["http://code.jquery.com/jquery.js"],
- done: function (errors, window) {
- var $ = (window).$;
- console.log("HN Links");
- $("td.title:not(:last) a").each(function() {
- console.log(" -", $(this).text());
- });
+ done: function (errors: Error[], window: Window) {
}
});
@@ -50,23 +43,9 @@ var jquery: string;
jsdom.env({
url: "http://news.ycombinator.com/",
src: [jquery],
- done: function (errors, window) {
- var $ = (window).$;
- console.log("HN Links");
- $("td.title:not(:last) a").each(function () {
- console.log(" -", $(this).text());
- });
+ done: function (errors: Error[], window: Window) {
}
});
-var window = jsdom.jsdom().parentWindow;
-var window = jsdom.jsdom("foobar
").parentWindow;
-var window = jsdom.jsdom("foobar
", {
-scripts: ["http://code.jquery.com/jquery.js"],
-done: function (errors, window) {
- var $ = (window).$;
- console.log("HN Links");
- $("td.title:not(:last) a").each(function() {
- console.log(" -", $(this).text());
- });
-}}).parentWindow;
\ No newline at end of file
+var window: Window = jsdom.jsdom("foobar
").parentWindow;
+var document: Document = jsdom.jsdom("");
\ No newline at end of file
diff --git a/jsdom/jsdom.d.ts b/jsdom/jsdom.d.ts
index 4dbcb086e..b9864b3b7 100644
--- a/jsdom/jsdom.d.ts
+++ b/jsdom/jsdom.d.ts
@@ -4,38 +4,140 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "jsdom" {
- export function env(config: Config): void;
- export function env(htmlRef: string, callback: Callback): void;
- export function env(htmlRef: string, scripts: string[], callback: Callback): void;
- export function env(htmlRef: string, config: Config, callback: Callback): void;
- export function env(htmlRef: string, scripts: string[], config: Config, callback: Callback): void;
- export function jsdom(markup?: string, options?: Config): Document;
+ /**
+ * The do-what-I-mean API.
+ *
+ * Example:
+ * jsdom.env(html, function (errors, window) {
+ * // free memory associated with the window
+ * window.close();
+ * });
+ *
+ * @param urlOrSource may be a URL, file name, or HTML fragment
+ * @param scriptUrlsOrSources a string or array of strings, containing file names or URLs that will be inserted as
+ * @param config Configuration object
+ * @param callback
+ */
+ export function env(urlOrHtml: string, scripts: string, config: Config, callback?: Callback): void;
+ export function env(urlOrHtml: string, scripts: string, callback: Callback): void;
+ export function env(urlOrHtml: string, scripts: string[], config: Config, callback?: Callback): void;
+ export function env(urlOrHtml: string, scripts: string[], callback: Callback): void;
+ export function env(urlOrHtml: string, callback: Callback): void;
+ export function env(urlOrHtml: string, config: Config, callback?: Callback): void;
+ export function env(config: Config, callback?: Callback): void;
- interface Callback {
+ /**
+ * The jsdom.jsdom method does less things automatically; it takes in only HTML source, and does not let you to
+ * separately supply script that it will inject and execute. It just gives you back a document object,
+ * with usable document.parentWindow, and starts asynchronously executing any