check translations, part switch links, MKWS-365
[mkws-moved-to-github.git] / test / spec / mkws-pazpar2.js
index e5140c2..e24a1bd 100644 (file)
@@ -740,6 +740,13 @@ describe("Check SortBy options", function () {
 
 describe("Check translations", function () {
     var $ = mkws.$;
+    // handle html entities, "Zurück" => "Zurück"
+    var M = function (string) {
+            return $("<span/>").html(mkws.M(string)).text()
+        };
+    var lang = function () {
+            return mkws.config.lang
+        };
 
     it("check language", function () {
         var lang = mkws.config.lang;
@@ -747,25 +754,96 @@ describe("Check translations", function () {
         expect(lang).toMatch(/^(de|da|)$/);
     });
 
+/*
+  locale_lang: {
+    "de": {
+      "Authors": "Autoren",
+      "Subjects": "Schlagw&ouml;rter",
+      "Sources": "Daten und Quellen",
+      "source": "datenquelle",
+      "Facets": "Termlisten",
+      "Next": "Weiter",
+      "Prev": "Zur&uuml;ck",
+      "Search": "Suche",
+      "Sort by": "Sortieren nach",
+      "and show": "und zeige",
+      "per page": "pro Seite",
+      "Displaying": "Zeige",
+      "to": "von",
+      "of": "aus",
+      "found": "gefunden",
+      "Title": "Titel",
+      "Author": "Autor",
+      "author": "autor",
+      "Date": "Datum",
+      "Subject": "Schlagwort",
+      "subject": "schlagwort",
+      "Location": "Ort",
+      "Records": "Datens&auml;tze",
+      "Targets": "Datenbanken",
+
+      "dummy": "dummy"
+    },
+*/
+
+    it("search button", function () {
+        var list = $(".mkws-switch > a")
+
+        expect(list.length).toBe(2);
+        expect($(list[0]).text()).toBe(M("Records"));
+        expect($(list[1]).text()).toBe(M("Targets"));
+    });
+
+    it("switch", function () {
+        var list = $(".mkws-pager-desc > span");
+        expect($("form > input[type=submit]").attr("value")).toBe(M("Search"));
+    });
+
+
     it("ranking form", function () {
         var list = $(".mkws-ranking > form > span");
-        var lang = mkws.config.lang;
 
         expect(list.length).toBe(3);
 
-        expect(mkws.M("Sort by")).toBe($(list[0]).text());
-        expect(mkws.M("and show")).toBe($(list[1]).text());
-        expect(mkws.M("per page")).toBe($(list[2]).text());
+        expect($(list[0]).text()).toBe(M("Sort by"));
+        expect($(list[1]).text()).toBe(M("and show"));
+        expect($(list[2]).text()).toBe(M("per page"));
 
         // double check
         if (lang == "de") {
-            expect(mkws.M("Sort by")).toBe("Sortieren nach");
-            expect($(list[0]).text()).toBe("Sortieren nach");
+            expect("Sortieren nach").toBe(M("Sort by"));
+            expect("Sortieren nach").toBe($(list[0]).text());
         } else if (lang == "da") {
-            expect(mkws.M("Sort by")).toBe("Sorter efter");
-            expect($(list[0]).text()).toBe("Sorter efter");
+            expect("Sorter efter").toBe(M("Sort by"));
+            expect("Sorter efter").toBe($(list[0]).text());
         }
     });
+
+    xit("facets", function () {
+        var list = $(".mkws-facet-title");
+
+        expect(list.length).toBe(3);
+
+        expect($(list[0]).text()).toBe(M("Sources"));
+        expect($(list[1]).text()).toBe(M("Subjects"));
+        expect($(list[2]).text()).toBe(M("Authors"));
+    });
+
+    it("navigation", function () {
+        var list = $(".mkws-pager-desc > span");
+
+        expect(list.length).toBe(4);
+
+        expect($(list[0]).text()).toBe(M("Displaying"));
+        expect($(list[1]).text()).toBe(M("to"));
+        expect($(list[2]).text()).toBe(M("of"));
+        expect($(list[3]).text()).toBe(M("found"));
+
+        expect($(".mkws-next").text()).toBe(M("Next"));
+        expect($(".mkws-prev").text()).toBe(M("Prev"));
+    });
+
+
 });
 
 xdescribe("Check async widget discovery", function () {