From: Roan Kattouw Date: Tue, 16 Aug 2011 13:33:22 +0000 (+0000) Subject: Followup r89853, tweaks for jquery.qunit.completenessTest: X-Git-Tag: 1.31.0-rc.0~28234 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=f764c6fab3b25e226ff2b47edbf6ad1dd5b8e8b0;p=lhc%2Fweb%2Fwiklou.git Followup r89853, tweaks for jquery.qunit.completenessTest: * Don't assume $ as a global, but alias it to jQuery instead. The code is already wrapped in a closure so this is easy * Remove unused constants TYPE_SIMPLEFUNC and TYPE_OBJCONSTRFUNC * Fix spelling in comments, mostly brake->break * Fix whitespace * Kill useless return at the end of a void function * Correct comment in hasTests() which claims the function does the opposite of what it really does --- diff --git a/resources/jquery/jquery.qunit.completenessTest.js b/resources/jquery/jquery.qunit.completenessTest.js index 2244237cb4..e93ba59527 100644 --- a/resources/jquery/jquery.qunit.completenessTest.js +++ b/resources/jquery/jquery.qunit.completenessTest.js @@ -5,7 +5,7 @@ * libraries. Written to be used in enviroments with jQuery and QUnit. * Requires jQuery 1.5.2 or higher. * - * Globals: jQuery, $, QUnit, console.log + * Globals: jQuery, QUnit, console.log * * Built for and tested with: * - Safari 5 @@ -13,11 +13,7 @@ * * @author Timo Tijhof, 2011 */ -(function(){ - -/* Private members */ -var TYPE_SIMPLEFUNC = 101; -var TYPE_OBJCONSTRFUNC = 100; +( function( $ ) { /** * CompletenessTest @@ -159,7 +155,7 @@ CompletenessTest.fn = CompletenessTest.prototype = { $.each( currVar.prototype, function( key, value ) { if ( key === 'constructor' ) return; - // Clone and brake reference to parentPathArray + // Clone and break reference to parentPathArray var tmpPathArray = $.extend( [], parentPathArray ); tmpPathArray.push( 'prototype' ); tmpPathArray.push( key ); @@ -174,11 +170,9 @@ CompletenessTest.fn = CompletenessTest.prototype = { if ( !currVar.prototype || $.isEmptyObject( currVar.prototype ) ) { // Inject check - that.injectCheck( masterVariable, parentPathArray, function(){ - + that.injectCheck( masterVariable, parentPathArray, function() { that.methodCallTracker[ parentPathArray.join( '.' ) ] = true; - - }, TYPE_SIMPLEFUNC ); + } ); // We don't support checking object constructors yet... } else { @@ -187,7 +181,7 @@ CompletenessTest.fn = CompletenessTest.prototype = { $.each( currVar.prototype, function( key, value ) { if ( key === 'constructor' ) return; - // Clone and brake reference to parentPathArray + // Clone and break reference to parentPathArray var tmpPathArray = $.extend( [], parentPathArray ); tmpPathArray.push( 'prototype' ); tmpPathArray.push( key ); @@ -197,12 +191,12 @@ CompletenessTest.fn = CompletenessTest.prototype = { } - // Recursively. After all, this *is* the completness test + // Recursively. After all, this *is* the completeness test } else if ( type === 'object' ) { $.each( currVar, function( key, value ) { - // Clone and brake reference to parentPathArray + // Clone and break reference to parentPathArray var tmpPathArray = $.extend( [], parentPathArray ); tmpPathArray.push( key ); @@ -211,8 +205,6 @@ CompletenessTest.fn = CompletenessTest.prototype = { } ); } - - return 'End of checkTests'; }, /** @@ -220,13 +212,13 @@ CompletenessTest.fn = CompletenessTest.prototype = { * * Checks if the given method name (ie. 'my.foo.bar') * was called during the test suite (as far as the tracker knows). - * If so it adds it to missingTests. + * If not it adds it to missingTests. * * @param fnName {String} * @return {Boolean} */ hasTest: function( fnName ) { - if ( !(fnName in this.methodCallTracker) ) { + if ( !( fnName in this.methodCallTracker ) ) { this.missingTests[fnName] = true; return false; } @@ -248,14 +240,14 @@ CompletenessTest.fn = CompletenessTest.prototype = { curr = masterVariable, lastMember; - $.each( objectPathArray, function(i, memberName){ + $.each( objectPathArray, function( i, memberName ) { prev = curr; curr = prev[memberName]; lastMember = memberName; }); // Objects are by reference, members (unless objects) are not. - prev[lastMember] = function(){ + prev[lastMember] = function() { injectFn(); return curr.apply( this, arguments ); }; @@ -264,4 +256,4 @@ CompletenessTest.fn = CompletenessTest.prototype = { window.CompletenessTest = CompletenessTest; -})(); +} )( jQuery );