From: Heikki Levanto Date: Thu, 6 Mar 2014 14:43:25 +0000 (+0100) Subject: Unit tests for the MOTD MKWS-134 X-Git-Tag: 1.0.0~1318^2~31 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=4ded4703dd42e64d3e4bd253c1298c35dbb9da7f;p=mkws-moved-to-github.git Unit tests for the MOTD MKWS-134 Added tests for the MOTD being moved to the right place before search and not being visible after search. Temporarily broke the code to verify my tests. --- diff --git a/examples/htdocs/jasmine-popup.html b/examples/htdocs/jasmine-popup.html index 3aac786..f979e63 100644 --- a/examples/htdocs/jasmine-popup.html +++ b/examples/htdocs/jasmine-popup.html @@ -52,5 +52,6 @@ This directory contains an embryonic MasterKey Widget Set, based initially on "jsdemo" though now far removed from those beginnnings. [...] +
This is the mkwsMOTD div
diff --git a/examples/htdocs/jasmine.html b/examples/htdocs/jasmine.html index 647be4b..af4f1e5 100644 --- a/examples/htdocs/jasmine.html +++ b/examples/htdocs/jasmine.html @@ -46,6 +46,7 @@ +
This is the mkwsMOTD div
diff --git a/notes/developers.txt b/notes/developers.txt index 14dd86a..66ee39a 100644 --- a/notes/developers.txt +++ b/notes/developers.txt @@ -62,9 +62,17 @@ Most (all?) code work happens in mkws.js. Unit tests ---------- +Tests are based on jasmine. a general description of jasmine is on +http://jasmine.github.io/1.3/introduction.html + If you want understand the test than you can look at mkws/test/spec/mkws-config.js and mkws/test/spec/mkws-pazpar2.js . See also mkws/test/README.txt +The test scripts are included from the test page, for example +mkws/examples/htdocs/jasmine-popup.html has + + + Structure of mkws.js diff --git a/test/spec/mkws-pazpar2.js b/test/spec/mkws-pazpar2.js index 41ad086..12677a8 100644 --- a/test/spec/mkws-pazpar2.js +++ b/test/spec/mkws-pazpar2.js @@ -75,6 +75,27 @@ describe("Init jasmine config", function () { }); }); +describe("Check MOTD before search", function () { + // Check that the MOTD has been moved into its container, and + // is visible before the search. + // the mkwsMOTD div was originally inside a testMOTD div, which should + // now be emtpy + // Note that the testMOTD is a regular div, and uses #testMOTD, + // since the automagic class-making does not apply to it. + it("MOTD is hidden", function () { + expect($(".mkwsMOTD").length).toBe(1); + expect($("#testMOTD").length).toBe(1); + expect($("#testMOTD").text()).toMatch("^ *$"); + }); + + it("mkwsMOTDContainer has received the text", function () { + expect($(".mkwsMOTDContainer").length).toBe(1); + expect($(".mkwsMOTDContainer").text()).toMatch(/MOTD/); + }); + + +}); + describe("Check pazpar2 search", function () { it("pazpar2 was successfully initialized", function () { expect(mkws_config.error).toBe(undefined); @@ -111,6 +132,18 @@ describe("Check pazpar2 search", function () { }); }); +describe("Check MOTD after search", function () { + it("MOTD is hidden", function () { + expect($(".mkwsMOTD").length).toBe(1); + expect($(".mkwsMOTD").is(":hidden")).toBe(true); + debug("motd " + $(".mkwsMOTD") ); + debug("motd t=" + $(".mkwsMOTD").text() ); + debug("motd v=" + $(".mkwsMOTD").is(":visible") ); + //expect($("div.mkwsBytarget").is(":visible")).toBe(true); + }); +}); + + /* * This part runs in background. It should be rewritten with