$(MIKE) jasmine-node --noColor --captureExceptions --forceexit spec
jsbeautifier jsb indent:
- for i in ./spec/*.js ./js/*.js; do \
+ for i in ./spec*/*.js ./js/*.js; do \
jsbeautifier -j $$i > $@.tmp && mv -f $@.tmp $$i; \
done
--- /dev/null
+describe("jsdom/jQuery suite simple", function () {
+ it("jsdom test", function () {
+ var jsdom = require("jsdom");
+ var DOMParser = require('xmldom').DOMParser;
+
+ var w = undefined;
+ var $ = undefined;
+
+ jsdom.env({
+ url: "http://mkws-dev.indexdata.com/jasmine-local-popup.html",
+ scripts: [""],
+ features: {
+ FetchExternalResources: ["script"]
+ },
+
+ done: function (errors, window) {
+ var DOMParser = require('xmldom').DOMParser;
+
+ w = window;
+ $ = window.$;
+
+ $(window).ready(function () {
+ console.log("document ready event");
+ console.log("mkws: " + window.mkws_config.pazpar2_url);
+
+ // setTimeout( function () { console.log("timeer...") }, 1000);
+ });
+
+ // spyOn(window, 'alert').andCallFake(function(msg) { console.log("fake allert: " + msg); });
+ window.alert = console.log;
+ window.console = console;
+
+ console.log("window.DOMParser: " + window.DOMParser);
+ console.log("window.document: " + window.document);
+
+
+ var xmlstring = "<rss version='2.0' jsessionId='CD8AFDD3040A81CFFDDD4EC066497139'><channel><title>RSS Title</title></channel></rss>";
+ $.parseXML = function (data) {
+ return new DOMParser().parseFromString(data)
+ };;
+ console.log("parseXML: " + $.parseXML(xmlstring).documentElement.getAttribute('jsessionId'));
+ }
+ });
+
+ waitsFor(function () {
+ if (!w) {
+ console.log(".");
+ } else if (w && !w.mkws) {
+ console.log("*");
+ } else {
+ // console.log("+");
+ }
+
+ return w && w.mkws && w.mkws.authenticated;
+ }, "window object done", 2 * 1000);
+
+ runs(function () {
+ console.log("got window");
+ console.log("got mkws auth: " + w.mkws.authenticated);
+ console.log("window.DOMParser: " + w.$.parseXML);
+ // console.log("W: " + $("html").text() );
+ expect(w).toBeDefined();
+ });
+
+ waitsFor(function () {
+ // console.log(".");
+ return w.mkws.jasmine_done;
+ }, "jasmine test done", 3 * 1000);
+
+ runs(function () {
+ console.log("jasmine test done: " + w.mkws.jasmine_done);
+ expect(w.mkws.jasmine_done).toBeTruthy();
+ });
+ });
+
+ it("jsdom test2", function () {
+ // expect($).toBeDefined();
+ });
+
+});
+
+console.log("EOF");
+
+/*
+jsdom.defaultDocumentFeatures = {
+ FetchExternalResources : ['script'],
+ ProcessExternalResources : ['script'],
+ MutationEvents : false,
+ QuerySelector : false
+};
+*/
--- /dev/null
+// Workaround for broken XML parser in node.js/jquery
+// see https://github.com/coolaj86/node-jquery/issues/29
+var jsdom = require("jsdom");
+var DOMParser = require('xmldom').DOMParser;
+var xmlstring = '<?xml version="1.0" encoding="UTF-8"?><process>yes</process>';
+
+jsdom.env('<html/>',
+// ["http://code.jquery.com/jquery.js"],
+
+
+function (errors, window) {
+ // var $ = window.$;
+ var $ = require('jQuery');
+
+ // override jquery xml parser with external XML lib xmldoc.DOMParser
+ $.parseXML = function (data) {
+ return new DOMParser().parseFromString(data)
+ };;
+
+ // parse XML string, extract "process" node and keep the text value of the node
+ var result = $($.parseXML(xmlstring)).find("process").text();
+
+ // should output "yes"
+ console.log("Testing jsdom/xmldom/jQuery $.parseXML() support: " + result);
+});
--- /dev/null
+describe("jsdom/jQuery suite simple", function () {
+ it("jsdom test", function () {
+ var jsdom = require("jsdom");
+
+ var $, w;
+ 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) {
+ console.log("contents of a.the-link:", window.$("a.the-link").text());
+ w = window;
+ $ = window.$;
+ });
+
+ waitsFor(function () {
+ if (!w) {
+ console.log(".");
+ }
+ return w;
+ }, "window object done", 2 * 1000);
+
+ runs(function () {
+ console.log("got window");
+ expect(w).toBeDefined();
+ expect(w.document).toBeDefined();
+ expect($.parseXML).toBeDefined();
+
+ var xmlstring = "<rss version='2.0' jsessionId='CD8AFDD3040A81CFFDDD4EC066497139'><channel><title>RSS Title</title></channel></rss>";
+
+ var DOMParser = require('xmldom').DOMParser;
+ var doc = new DOMParser().parseFromString(xmlstring);
+ console.log("doc: " + doc.documentElement.getAttribute('jsessionId'));
+
+ var xmlDoc = doc; // $.parseXML(xml);
+ var xml = $(xmlDoc);
+ var title = xml.find("title");
+
+ console.log("title: " + $(title).text());
+ $.parseXML = function (data) {
+ return new DOMParser().parseFromString(data)
+ };;
+
+ console.log("parseXML: " + $($.parseXML(xmlstring)).text());
+
+ // console.log(w.document);
+ })
+ });
+
+});
+
+console.log("EOF");
jsdom_check('../examples/htdocs/language.html', [utils.tags.required, utils.tags.optional, utils.tags.optional2]);
jsdom_check('../examples/htdocs/mobile.html', [utils.tags.required, utils.tags.optional]);
jsdom_check('../examples/htdocs/index.html', [utils.tags.required, utils.tags.optional]);
-
}
debug("jasmine config: " + key + " => " + jasmine_config[key]);
}
+
+ mkws.jasmine_done = false;
}
var get_hit_counter = function () {
});
-/* dummy EOF */
+/* done */
describe("All tests are done", function () {
- it(">>> hooray <<<", function () {});
+ it(">>> hooray <<<", function () {
+ mkws.jasmine_done = true;
+ });
});