Unit tests for the MOTD MKWS-134
authorHeikki Levanto <heikki@indexdata.dk>
Thu, 6 Mar 2014 14:43:25 +0000 (15:43 +0100)
committerHeikki Levanto <heikki@indexdata.dk>
Thu, 6 Mar 2014 14:43:25 +0000 (15:43 +0100)
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.

examples/htdocs/jasmine-popup.html
examples/htdocs/jasmine.html
notes/developers.txt
test/spec/mkws-pazpar2.js

index 3aac786..f979e63 100644 (file)
@@ -52,5 +52,6 @@ This directory contains an embryonic MasterKey Widget Set, based
 initially on "jsdemo" though now far removed from those beginnnings.
 [...]
     </pre>
 initially on "jsdemo" though now far removed from those beginnnings.
 [...]
     </pre>
+     <div id="testMOTD"><div id="mkwsMOTD">This is the mkwsMOTD div</div></div>
   </body>
 </html>
   </body>
 </html>
index 647be4b..af4f1e5 100644 (file)
@@ -46,6 +46,7 @@
 
   </head>
   <body>
 
   </head>
   <body>
+    <div id="testMOTD"><div id="mkwsMOTD">This is the mkwsMOTD div</div></div>
     <table width="100%" border="0">
       <tr>
         <td>
     <table width="100%" border="0">
       <tr>
         <td>
index 14dd86a..66ee39a 100644 (file)
@@ -62,9 +62,17 @@ Most (all?) code work happens in mkws.js.
 Unit tests
 ----------
 
 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
 
 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 
+<script type="text/javascript" src="test/spec/mkws-pazpar2.js"></script>
+
+
 
 
 Structure of mkws.js
 
 
 Structure of mkws.js
index 41ad086..12677a8 100644 (file)
@@ -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);
 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
 
 /*
  * This part runs in background. It should be rewritten with