+// get references from mkws.js, lazy evaluation
+var debug = function (text) {
+ mkws.log("Jasmine: " + text)
+ }
+
+ // Define empty jasmine_config for simple applications that don't define it.
+if (jasmine_config == null || typeof jasmine_config != 'object') {
+ var jasmine_config = {};
+}
+
+var jasmine_status = {
+ source_click: 0
+};
+
+/* check config for jasmine test
+ *
+ * you can override the default values in the config
+ * object: jasmine_config = {};
+ *
+ */
+function init_jasmine_config() {
+
+ var jasmine_config_default = {
+ search_query: "freebsd",
+ max_time: 17,
+ // in seconds
+ expected_hits: 80,
+ // at least expected hit counter
+ second: 1000,
+ // miliseconds to seconds
+ show_record_url: true,
+ // check for valid URL in records
+ check_motd: true,
+ dummy: false
+ };
+
+ // use default values for undefined values
+ for (var key in jasmine_config_default) {
+ if (!jasmine_config.hasOwnProperty(key)) {
+ jasmine_config[key] = jasmine_config_default[key];
+ }
+ debug("jasmine config: " + key + " => " + jasmine_config[key]);
+ }
+
+ mkws.jasmine_done = false;
+}
+
+var get_hit_counter = function () {
+ // not yet here
+ if ($(".mkwsPager").length == 0) return -1;
+
+ var found = $(".mkwsPager").text();
+ var re = /\([A-Za-z]+:\s+([0-9]+)\)/;
+ re.exec(found);
+ var hits = -1;
+
+ if (RegExp.$1) {
+ hits = parseInt(RegExp.$1);
+ if (hits <= 0) {
+ debug("Oooops in get_hit_counter: " + RegExp.$1 + " '" + found + "'");
+ }
+ }
+
+ //debug("Hits: " + hits);
+ return hits;
+ }
+
+describe("Init jasmine config", function () {
+ it("jasmine was successfully initialized", function () {
+ init_jasmine_config();
+
+ expect(jasmine_config.search_query).toMatch(/\w/);
+ expect(jasmine_config.second).toBeGreaterThan(100);
+ expect(jasmine_config.max_time).toBeGreaterThan(1);
+ expect(jasmine_config.expected_hits).toBeGreaterThan(1);
+ });
+});
+
+//disabled
+xdescribe("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 empty
+ // 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/);
+ });
+});
+