new target check-dev
[mkws-moved-to-github.git] / test / spec-dev / parseXML.spec.js
1 xdescribe("jsdom/jQuery suite simple", function () {
2     it("jsdom test", function () {
3         var jsdom = require("jsdom");
4
5         var $, w;
6         jsdom.env('<p><a class="the-link" href="http://indexdata.com">jsdom\'s Homepage</a></p>', ["http://code.jquery.com/jquery.js"], function (errors, window) {
7             console.log("contents of a.the-link:", window.$("a.the-link").text());
8             w = window;
9             $ = window.$;
10         });
11
12         waitsFor(function () {
13             if (!w) {
14                 console.log(".");
15             }
16             return w;
17         }, "window object done", 2 * 1000);
18
19         runs(function () {
20             console.log("got window");
21             expect(w).toBeDefined();
22             expect(w.document).toBeDefined();
23             expect($.parseXML).toBeDefined();
24
25             var xmlstring = "<rss version='2.0' jsessionId='CD8AFDD3040A81CFFDDD4EC066497139'><channel><title>RSS Title</title></channel></rss>";
26
27             var DOMParser = require('xmldom').DOMParser;
28             var doc = new DOMParser().parseFromString(xmlstring);
29             console.log("doc: " + doc.documentElement.getAttribute('jsessionId'));
30
31             var xmlDoc = doc; // $.parseXML(xml);
32             var xml = $(xmlDoc);
33             var title = xml.find("title");
34
35             console.log("title: " + $(title).text());
36             $.parseXML = function (data) {
37                 return new DOMParser().parseFromString(data)
38             };;
39
40             console.log("parseXML: " + $($.parseXML(xmlstring)).text());
41
42             // console.log(w.document);
43         })
44     });
45
46 });
47
48 console.log("EOF");