diff options
author | Thomas Schmid <schmid-thomas@gmx.net> | 2018-11-14 04:58:00 +0300 |
---|---|---|
committer | Thomas Schmid <schmid-thomas@gmx.net> | 2018-11-14 04:58:00 +0300 |
commit | 429904e12fefff0148056e557f55da4572b0cacf (patch) | |
tree | 6689284e4070706c4d3b77e9e1ec632d9cd25bc4 /tests | |
parent | bd76129749a588c96b6c48e09175466c850ebdf2 (diff) |
Address linter warnings
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/js/Suite.js | 314 | ||||
-rwxr-xr-x | tests/js/UnitInit.js | 10 |
2 files changed, 162 insertions, 162 deletions
diff --git a/tests/js/Suite.js b/tests/js/Suite.js index 30525865..9138a01d 100755 --- a/tests/js/Suite.js +++ b/tests/js/Suite.js @@ -5,160 +5,160 @@ // Our server is implemented within an anonymous method... -(function(exports) { +(function (exports) { "use strict"; - /* global $: false */ - /* global net */ + /* global $: false */ + /* global net */ /* global tests */ - /* global document */ - + /* global document */ + // Create the namespace, even if we are inside an anonymous method... if (!exports.net) exports.net = {}; - + if (!exports.net.tschmid) exports.net.tschmid = {}; - + if (!exports.net.tschmid.yautt) - exports.net.tschmid.yautt = {}; - + exports.net.tschmid.yautt = {}; + if (!exports.net.tschmid.yautt.test) exports.net.tschmid.yautt.test = {}; - + if (!exports.net.tschmid.yautt.test.server) exports.net.tschmid.yautt.test.server = {}; - + if (!exports.net.tschmid.yautt.test.server.queue) exports.net.tschmid.yautt.test.server.queue = []; - + if (!exports.net.tschmid.yautt.test.server.current) exports.net.tschmid.yautt.test.server.current = null; - - exports.net.tschmid.yautt.test.server.onMessage = function(event) { + + exports.net.tschmid.yautt.test.server.onMessage = function (event) { let msg = JSON.parse(event.data); - - if ( msg.type === "LOG" ) { + + if (msg.type === "LOG") { this.log(msg.data, msg.level); return; } - + let that = this; - - if ( msg.type === "FAIL" ) { - - this.log( "##### Test failed: " + msg.description, "Fail" ); - if ( msg.details ) - this.log( "" + msg.details, "Trace" ); + if (msg.type === "FAIL") { + + this.log("##### Test failed: " + msg.description, "Fail"); + + if (msg.details) + this.log("" + msg.details, "Trace"); // The post event blocks both window. So defere processing... - window.setTimeout(function() {that.next();}, 10); - - $("#tests input[value='"+this.current+"']").parent("div").css("color", "red"); - + window.setTimeout(function () { that.next(); }, 10); + + $("#tests input[value='" + this.current + "']").parent("div").css("color", "red"); + return; } - - if ( msg.type === "SUCCEED" ) { - this.log("##### Test succeeded.","Success"); + + if (msg.type === "SUCCEED") { + this.log("##### Test succeeded.", "Success"); // The post event blocks both window. So defere processing... - window.setTimeout(function() {that.next();}, 10); - - $("#tests input[value='"+this.current+"']").parent("div").css("color", "green"); + window.setTimeout(function () { that.next(); }, 10); + + $("#tests input[value='" + this.current + "']").parent("div").css("color", "green"); return; - } - + } + alert("Unknown post received"); }; - - net.tschmid.yautt.test.server.log = function(message, style) { - - if (typeof(style) !== "string") - style = "logInfo"; - else - style = "log"+style; - + + net.tschmid.yautt.test.server.log = function (message, style) { + + if (typeof (style) !== "string") + style = "logInfo"; + else + style = "log" + style; + $("<div/>") .addClass(style) .text(message) - .appendTo( "#divOutput > div:last-child" ); + .appendTo("#divOutput > div:last-child"); }; - net.tschmid.yautt.test.server.logTrace = function(message) { - this.log(message, "Trace"); + net.tschmid.yautt.test.server.logTrace = function (message) { + this.log(message, "Trace"); }; - - net.tschmid.yautt.test.server.logError = function(message) { - this.log(message, "Error"); + + net.tschmid.yautt.test.server.logError = function (message) { + this.log(message, "Error"); }; - - net.tschmid.yautt.test.server.startLog = function ( test ) { - $( "<div/>" ) - .attr( "testprofile", test ) - .appendTo( "#divOutput" ); + + net.tschmid.yautt.test.server.startLog = function (test) { + $("<div/>") + .attr("testprofile", test) + .appendTo("#divOutput"); }; net.tschmid.yautt.test.server.extend = function (name) { - - var base = exports.net.tschmid.yautt.test.config[name]; - var scripts = []; - + + let base = exports.net.tschmid.yautt.test.config[name]; + let scripts = []; + if (!base) return []; - + if (base.extend) - scripts = this.extend(base.extend); - + scripts = this.extend(base.extend); + if (!base.require) return scripts; - + // TODO Check/ensure if require is an array... $.each(base.require, function (idx, value) { scripts.push(value); }); - + return scripts; }; - net.tschmid.yautt.test.server.next = function() { - - this.current = this.queue.shift(); - - if (typeof(this.current) === "undefined") - return; - - this.startLog( this.current ); - this.log( "Test profile '" + this.current + "'", "Header" ); - var scripts = this.extend(this.current); - - var tests = exports.net.tschmid.yautt.test.config; - + net.tschmid.yautt.test.server.next = function () { + + this.current = this.queue.shift(); + + if (typeof (this.current) === "undefined") + return; + + this.startLog(this.current); + this.log("Test profile '" + this.current + "'", "Header"); + let scripts = this.extend(this.current); + + let tests = exports.net.tschmid.yautt.test.config; + scripts.push("./../js/Unit.js"); scripts.push(tests[this.current].script); scripts.push("./../js/UnitInit.js"); - + let that = this; - + $("#divFrame") .empty() .append($("<iframe/>") - .attr("id","testFrame") - .load(function() { + .attr("id", "testFrame") + .load(function () { let iframe = document.getElementById("testFrame").contentWindow; - that.logTrace("Injecting Scripts for "+that.current+" ..."); - - $.each(scripts, function (idx,script) { - + that.logTrace("Injecting Scripts for " + that.current + " ..."); + + $.each(scripts, function (idx, script) { + let msg = { type: "IMPORT", data: script }; - - iframe.postMessage(""+JSON.stringify(msg) ,"*"); + + iframe.postMessage("" + JSON.stringify(msg), "*"); }); }) - .attr("src","./tests/tests.html")); + .attr("src", "./tests/tests.html")); }; /** @@ -169,137 +169,137 @@ * the tests which should be performed * @returns{undefined} */ - net.tschmid.yautt.test.server.add = function ( tests ) { + net.tschmid.yautt.test.server.add = function (tests) { - var config = exports.net.tschmid.yautt.test.config; + let config = exports.net.tschmid.yautt.test.config; - if ( config === null || typeof ( config ) === "undefined" ) + if (config === null || typeof (config) === "undefined") config = {}; - $.each( tests, function ( name, value ) { - if ( typeof ( value ) === "undefined" ) + $.each(tests, function (name, value) { + if (typeof (value) === "undefined") return; - + config[name] = value; }); exports.net.tschmid.yautt.test.config = config; }; - net.tschmid.yautt.test.server.run = function() { - + net.tschmid.yautt.test.server.run = function () { + let that = this; - + this.queue = []; - - var tests = exports.net.tschmid.yautt.test.config; + + let tests = exports.net.tschmid.yautt.test.config; $.each(tests, function (name, value) { // Loop through tests.. - if (typeof(value) === "undefined") - return; + if (typeof (value) === "undefined") + return; if (value.disabled) - return; - - if (!value.script) - return; - - that.queue.push(name); + return; + + if (!value.script) + return; + + that.queue.push(name); }); - - this.next(); + + this.next(); // TODO add a timeout watchdog. }; - + /** * Clears all results... * @returns{undefined} */ net.tschmid.yautt.test.server.clear = function () { - $( "#divOutput" ).empty(); + $("#divOutput").empty(); - $( "#tests div" ).each( function () { - $( this ).css( "color", "" ); + $("#tests div").each(function () { + $(this).css("color", ""); }); }; - net.tschmid.yautt.test.server.init = function() { + net.tschmid.yautt.test.server.init = function () { let that = this; - window.addEventListener("message", function(event) { that.onMessage(event); }, false); + window.addEventListener("message", function (event) { that.onMessage(event); }, false); }; - - - $(document).ready(function() { - - net.tschmid.yautt.test.server.init(); - - $("#toggleTrace").click(function(){ + + + $(document).ready(function () { + + net.tschmid.yautt.test.server.init(); + + $("#toggleTrace").click(function () { $(".logTrace").toggle(); }); - - $("#start").click(function() { - var tests = exports.net.tschmid.yautt.test.config; + $("#start").click(function () { + + let tests = exports.net.tschmid.yautt.test.config; + + $.each(tests, function (name, value) { + if (value.disabled) + value.disabled = false; + }); - $.each(tests, function(name,value) { - if(value.disabled) - value.disabled = false; - }); - let items = $("#tests input:checkbox:not(:checked)"); items.each(function (idx, elm) { let name = $(this).val(); - - if (tests[name].script) - tests[name].disabled = true; - }); - + + if (tests[name].script) + tests[name].disabled = true; + }); + net.tschmid.yautt.test.server.clear(); net.tschmid.yautt.test.server.run(); }); - + $("#tests-none").click(function () { - $( "#tests input:checkbox" ).each(function() { + $("#tests input:checkbox").each(function () { $(this).prop("checked", false); }); }); $("#tests-all").click(function () { - $( "#tests input:checkbox" ).each(function() { + $("#tests input:checkbox").each(function () { $(this).prop("checked", true); }); }); - - $("#result-clear").click(function() { + + $("#result-clear").click(function () { $("#divOutput").empty(); $("#tests div").each(function () { $(this).css("color", ""); }); }); - - - var elm = $("#tests"); - var tests = exports.net.tschmid.yautt.test.config; - - $.each( tests, function ( name ) { - if (!tests[name].script) - return; - function gotoTest( name ) { - var items = $( "#divOutput [testprofile='" + name + "']" ); + let elm = $("#tests"); + let tests = exports.net.tschmid.yautt.test.config; + + $.each(tests, function (name) { + + if (!tests[name].script) + return; + + function gotoTest(name) { + var items = $("#divOutput [testprofile='" + name + "']"); - items.last().get( 0 ).scrollIntoView(); + items.last().get(0).scrollIntoView(); } - - elm.append( - $("<div />") - .append($("<input />", { type:"checkbox", "checked":"checked" }).val(name)) - .append( $( "<span />" ).text( name ).click( function () { gotoTest( name ); }) ) ); - + + elm.append( + $("<div />") + .append($("<input />", { type: "checkbox", "checked": "checked" }).val(name)) + .append($("<span />").text(name).click(function () { gotoTest(name); }))); + }); }); -}(window)); +})(window); diff --git a/tests/js/UnitInit.js b/tests/js/UnitInit.js index 4b2e8bee..b4c99194 100755 --- a/tests/js/UnitInit.js +++ b/tests/js/UnitInit.js @@ -1,13 +1,13 @@ /** * Starts the unit test. - * + * * This javascript file has to be loaded as last file for each unit. */ -( function () { - "use strict"; +(function () { + "use strict"; - /*global net */ - net.tschmid.yautt.test.run(); + /* global net */ + net.tschmid.yautt.test.run(); })(); |