From: Wolfram Schneider
Date: Thu, 30 Jan 2014 17:22:52 +0000 (+0000)
Subject: Merge branch 'master' of ssh://git.indexdata.com:222/home/git/private/mkws
X-Git-Tag: 1.0.0~1564
X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=19bf7dddb65a1f2cf9b86bd0d82e604cfdedc05c;hp=70bfae57902896a69e8bf4b4261574c555afcf46;p=mkws-moved-to-github.git
Merge branch 'master' of ssh://git.indexdata.com:222/home/git/private/mkws
---
diff --git a/test/Makefile b/test/Makefile
index e2d8fc2..33c5fb3 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -24,7 +24,7 @@ terse:
$(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
diff --git a/test/spec-dev/mkws.spec.js b/test/spec-dev/mkws.spec.js
new file mode 100644
index 0000000..2e6e3ea
--- /dev/null
+++ b/test/spec-dev/mkws.spec.js
@@ -0,0 +1,91 @@
+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 Title";
+ $.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
+};
+*/
diff --git a/test/spec-dev/parseXML.js b/test/spec-dev/parseXML.js
new file mode 100644
index 0000000..8c6a32f
--- /dev/null
+++ b/test/spec-dev/parseXML.js
@@ -0,0 +1,25 @@
+// 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 = 'yes';
+
+jsdom.env('',
+// ["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);
+});
diff --git a/test/spec-dev/parseXML.spec.js b/test/spec-dev/parseXML.spec.js
new file mode 100644
index 0000000..6827642
--- /dev/null
+++ b/test/spec-dev/parseXML.spec.js
@@ -0,0 +1,48 @@
+describe("jsdom/jQuery suite simple", function () {
+ it("jsdom test", function () {
+ var jsdom = require("jsdom");
+
+ var $, w;
+ jsdom.env('
jsdom\'s Homepage
', ["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 Title";
+
+ 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");
diff --git a/test/spec-sp/mkws-index-jsdom.spec.js b/test/spec-sp/mkws-index-jsdom.spec.js
index ea22425..fe0dbdf 100644
--- a/test/spec-sp/mkws-index-jsdom.spec.js
+++ b/test/spec-sp/mkws-index-jsdom.spec.js
@@ -53,4 +53,3 @@ function jsdom_check(file, tags_array, ignore_doctype) {
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]);
-
diff --git a/test/spec/mkws-pazpar2.js b/test/spec/mkws-pazpar2.js
index 03c7bd9..d0bf9e8 100644
--- a/test/spec/mkws-pazpar2.js
+++ b/test/spec/mkws-pazpar2.js
@@ -42,6 +42,8 @@ function init_jasmine_config() {
}
debug("jasmine config: " + key + " => " + jasmine_config[key]);
}
+
+ mkws.jasmine_done = false;
}
var get_hit_counter = function () {
@@ -384,7 +386,9 @@ describe("Check status client counter", function () {
});
-/* dummy EOF */
+/* done */
describe("All tests are done", function () {
- it(">>> hooray <<<", function () {});
+ it(">>> hooray <<<", function () {
+ mkws.jasmine_done = true;
+ });
});