diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-04-23 08:44:55 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-04-23 08:44:55 -0400 |
commit | 3b54760b51fde0e541d2b47c34475ab29a4eea79 (patch) | |
tree | 232b22d4e1bd939a84d2c99f8a16deda63a5a91b /tests/unit/testsuite.js | |
parent | 822e1c500976634f0b9c49e6ad40aa6ec172e9e0 (diff) | |
download | jquery-ui-3b54760b51fde0e541d2b47c34475ab29a4eea79.tar.gz jquery-ui-3b54760b51fde0e541d2b47c34475ab29a4eea79.zip |
Tests: Run JSHint in unit tests, unless nojshint=1 is specified in the query string.
Diffstat (limited to 'tests/unit/testsuite.js')
-rw-r--r-- | tests/unit/testsuite.js | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index a877e38af..70d035684 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -1,7 +1,41 @@ -(function() { +(function( $ ) { window.TestHelpers = {}; +function testJshint( widget ) { + if ( QUnit.urlParams.nojshint ) { + return; + } + + document.write( "<script src='../../../external/jshint.js'></script>" ); + asyncTest( "JSHint", function() { + expect( 1 ); + + $.when( + $.ajax({ + url: "../../../ui/.jshintrc", + dataType: "json" + }), + $.ajax({ + url: "../../../ui/jquery.ui." + widget + ".js", + dataType: "text" + }) + ).done(function( hintArgs, srcArgs ) { + var passed = JSHINT( srcArgs[ 0 ], hintArgs[ 0 ] ), + errors = $.map( JSHINT.errors, function( error ) { + return "[L" + error.line + ":C" + error.character + "] " + + error.reason + "\n" + error.evidence + "\n"; + }).join( "\n" ); + ok( passed, errors ); + start(); + }) + .fail(function() { + ok( false, "error loading source" ); + start(); + }); + }); +} + function testWidgetDefaults( widget, defaults ) { var pluginDefaults = $.ui[ widget ].prototype.options; @@ -59,6 +93,7 @@ function testBasicUsage( widget ) { TestHelpers.commonWidgetTests = function( widget, settings ) { module( widget + ": common widget" ); + testJshint( widget ); testWidgetDefaults( widget, settings.defaults ); testWidgetOverrides( widget ); testBasicUsage( widget ); @@ -106,4 +141,4 @@ window.domEqual = function( selector, modifier, message ) { QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); }; -}()); +}( jQuery )); |