Index: trunk/phase3/resources/jquery/jquery.qunit.completenessTest.js |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * libraries. Written to be used in enviroments with jQuery and QUnit. |
7 | 7 | * Requires jQuery 1.5.2 or higher. |
8 | 8 | * |
9 | | - * Globals: jQuery, $, QUnit, console.log |
| 9 | + * Globals: jQuery, QUnit, console.log |
10 | 10 | * |
11 | 11 | * Built for and tested with: |
12 | 12 | * - Safari 5 |
— | — | @@ -13,12 +13,8 @@ |
14 | 14 | * |
15 | 15 | * @author Timo Tijhof, 2011 |
16 | 16 | */ |
17 | | -(function(){ |
| 17 | +( function( $ ) { |
18 | 18 | |
19 | | -/* Private members */ |
20 | | -var TYPE_SIMPLEFUNC = 101; |
21 | | -var TYPE_OBJCONSTRFUNC = 100; |
22 | | - |
23 | 19 | /** |
24 | 20 | * CompletenessTest |
25 | 21 | * @constructor |
— | — | @@ -159,7 +155,7 @@ |
160 | 156 | $.each( currVar.prototype, function( key, value ) { |
161 | 157 | if ( key === 'constructor' ) return; |
162 | 158 | |
163 | | - // Clone and brake reference to parentPathArray |
| 159 | + // Clone and break reference to parentPathArray |
164 | 160 | var tmpPathArray = $.extend( [], parentPathArray ); |
165 | 161 | tmpPathArray.push( 'prototype' ); tmpPathArray.push( key ); |
166 | 162 | |
— | — | @@ -174,12 +170,10 @@ |
175 | 171 | if ( !currVar.prototype || $.isEmptyObject( currVar.prototype ) ) { |
176 | 172 | |
177 | 173 | // Inject check |
178 | | - that.injectCheck( masterVariable, parentPathArray, function(){ |
179 | | - |
| 174 | + that.injectCheck( masterVariable, parentPathArray, function() { |
180 | 175 | that.methodCallTracker[ parentPathArray.join( '.' ) ] = true; |
| 176 | + } ); |
181 | 177 | |
182 | | - }, TYPE_SIMPLEFUNC ); |
183 | | - |
184 | 178 | // We don't support checking object constructors yet... |
185 | 179 | } else { |
186 | 180 | |
— | — | @@ -187,7 +181,7 @@ |
188 | 182 | $.each( currVar.prototype, function( key, value ) { |
189 | 183 | if ( key === 'constructor' ) return; |
190 | 184 | |
191 | | - // Clone and brake reference to parentPathArray |
| 185 | + // Clone and break reference to parentPathArray |
192 | 186 | var tmpPathArray = $.extend( [], parentPathArray ); |
193 | 187 | tmpPathArray.push( 'prototype' ); tmpPathArray.push( key ); |
194 | 188 | |
— | — | @@ -197,12 +191,12 @@ |
198 | 192 | |
199 | 193 | } |
200 | 194 | |
201 | | - // Recursively. After all, this *is* the completness test |
| 195 | + // Recursively. After all, this *is* the completeness test |
202 | 196 | } else if ( type === 'object' ) { |
203 | 197 | |
204 | 198 | $.each( currVar, function( key, value ) { |
205 | 199 | |
206 | | - // Clone and brake reference to parentPathArray |
| 200 | + // Clone and break reference to parentPathArray |
207 | 201 | var tmpPathArray = $.extend( [], parentPathArray ); |
208 | 202 | tmpPathArray.push( key ); |
209 | 203 | |
— | — | @@ -211,8 +205,6 @@ |
212 | 206 | } ); |
213 | 207 | |
214 | 208 | } |
215 | | - |
216 | | - return 'End of checkTests'; |
217 | 209 | }, |
218 | 210 | |
219 | 211 | /** |
— | — | @@ -220,13 +212,13 @@ |
221 | 213 | * |
222 | 214 | * Checks if the given method name (ie. 'my.foo.bar') |
223 | 215 | * was called during the test suite (as far as the tracker knows). |
224 | | - * If so it adds it to missingTests. |
| 216 | + * If not it adds it to missingTests. |
225 | 217 | * |
226 | 218 | * @param fnName {String} |
227 | 219 | * @return {Boolean} |
228 | 220 | */ |
229 | 221 | hasTest: function( fnName ) { |
230 | | - if ( !(fnName in this.methodCallTracker) ) { |
| 222 | + if ( !( fnName in this.methodCallTracker ) ) { |
231 | 223 | this.missingTests[fnName] = true; |
232 | 224 | return false; |
233 | 225 | } |
— | — | @@ -248,14 +240,14 @@ |
249 | 241 | curr = masterVariable, |
250 | 242 | lastMember; |
251 | 243 | |
252 | | - $.each( objectPathArray, function(i, memberName){ |
| 244 | + $.each( objectPathArray, function( i, memberName ) { |
253 | 245 | prev = curr; |
254 | 246 | curr = prev[memberName]; |
255 | 247 | lastMember = memberName; |
256 | 248 | }); |
257 | 249 | |
258 | 250 | // Objects are by reference, members (unless objects) are not. |
259 | | - prev[lastMember] = function(){ |
| 251 | + prev[lastMember] = function() { |
260 | 252 | injectFn(); |
261 | 253 | return curr.apply( this, arguments ); |
262 | 254 | }; |
— | — | @@ -264,4 +256,4 @@ |
265 | 257 | |
266 | 258 | window.CompletenessTest = CompletenessTest; |
267 | 259 | |
268 | | -})(); |
| 260 | +} )( jQuery ); |