aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-04-23 08:44:55 -0400
committerScott González <scott.gonzalez@gmail.com>2012-04-23 08:44:55 -0400
commit3b54760b51fde0e541d2b47c34475ab29a4eea79 (patch)
tree232b22d4e1bd939a84d2c99f8a16deda63a5a91b /tests
parent822e1c500976634f0b9c49e6ad40aa6ec172e9e0 (diff)
downloadjquery-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')
-rw-r--r--tests/resource_loader.js5
-rw-r--r--tests/unit/testsuite.js39
2 files changed, 40 insertions, 4 deletions
diff --git a/tests/resource_loader.js b/tests/resource_loader.js
index c8dec4881..9a03411a2 100644
--- a/tests/resource_loader.js
+++ b/tests/resource_loader.js
@@ -24,8 +24,9 @@ function includeScript( url ) {
window.loadResources = min ?
function() {
- includeStyle( "build/dist/theme/jquery-ui.min.css" );
- includeScript( "build/dist/jquery-ui.min.js" );
+ // TODO: proper include with theme images
+ includeStyle( "dist/jquery-ui.min.css" );
+ includeScript( "dist/jquery-ui.min.js" );
} :
function( resources ) {
$.each( resources.css || [], function( i, resource ) {
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 ));