1 /* Copyright (c) 2013-2015 Index Data ApS. http://indexdata.com
3 * perform papzpar2 / pz2.js search & retrieve request in the browser
10 // get references from mkws.js, lazy evaluation
11 var debug = function (text) {
12 // use a debug function with time stamps
13 console.log("Jasmine: " + text);
15 //mkws.log("Jasmine: " + text)
18 // Define empty jasmine_config for simple applications that don't define it.
19 if (jasmine_config == null || typeof jasmine_config != 'object') {
20 var jasmine_config = {};
23 var jasmine_status = {
27 /* check config for jasmine test
29 * you can override the default values in the config
30 * object: jasmine_config = {};
33 function init_jasmine_config() {
35 var jasmine_config_default = {
36 // tune parameter for batch testing
39 search_query: "freebsd",
43 // at least expected hit counter
45 // miliseconds to seconds
46 show_record_url: true,
47 // check for valid URL in records
50 // check sort by and per page menu
56 // use default values for undefined values
57 for (var key in jasmine_config_default) {
58 if (!jasmine_config.hasOwnProperty(key)) {
59 jasmine_config[key] = jasmine_config_default[key];
61 debug("jasmine config: " + key + " => " + jasmine_config[key]);
65 mkws.jasmine_done = false;
68 /******************************************************************************/
69 describe("Init jasmine config", function () {
70 it("jasmine was successfully initialized", function () {
71 init_jasmine_config();
73 expect(jasmine_config.search_query).toMatch(/\w/);
74 expect(jasmine_config.second).toBeGreaterThan(100);
75 expect(jasmine_config.max_time).toBeGreaterThan(1);
76 expect(jasmine_config.expected_hits).toBeGreaterThan(1);
81 // temporary disabled due records without an author, MKWS-400
82 describe("Check translations", function () {
83 var $ = function (string) {
87 // handle html entities, "Zurück" => "Zurück"
88 var M = function (string) {
92 function check_translation(list, text) {
93 expect(list.length).toBe(text.length);
95 for (var i = 0; i < text.length; i++) {
96 expect($(list[i]).text().match(M(text[i]))).not.toBeNull();
103 "Authors": "Autoren",
104 "Subjects": "Schlagwörter",
105 "Sources": "Daten und Quellen",
106 "source": "datenquelle",
107 "Facets": "Termlisten",
109 "Prev": "Zurück",
111 "Sort by": "Sortieren nach",
112 "and show": "und zeige",
113 "per page": "pro Seite",
114 "Displaying": "Zeige",
122 "Subject": "Schlagwort",
123 "subject": "schlagwort",
124 "Location": "Bestand",
125 "Locations": "Bestand",
126 "Records": "Datensätze",
127 "Targets": "Datenbanken",
128 "relevance": "Relevanz",
131 "oldest": "Älteste",
137 function check_translation_list(keywords, list) {
139 for (var i = 0; i < keywords.length; i++) {
140 if ($(list[i]).match("^" + M(keywords[i]) + ": ")) {
141 debug("found: " + list[i] + " :: " + keywords[i]);
143 debug("NOT found: " + list[i] + " :: " + keywords[i]);
144 errors.push(keywords[i])
147 expect(errors.length).not.toBeGreaterThan(1);
151 it("record details", function () {
152 var keywords = ["Title", "Date", "Author"]; // , "Subject", "Locations"];
153 var list = ["Title: foo", "Date: bar", "Author: wolfram", "Location: bla"];
154 var list_de = ["Titel: foo", "Datum: bar", "Autor: wolfram", "Location: bla"];
155 var keywords_de = [];
157 check_translation_list(keywords, list);
159 for (var i = 0; i < keywords.length; i++) {
160 keywords_de.push(locale_lang["de"][keywords[i]]);
163 check_translation_list(keywords_de, list_de);
169 describe("All tests are done", function () {
170 it(">>> hooray <<<", function () {
171 mkws.jasmine_done = true;
172 debug(">>> hooray <<<");