Tests: Run JSHint in unit tests, unless nojshint=1 is specified in the query string.

This commit is contained in:
Scott González 2012-04-23 08:44:55 -04:00
parent 822e1c5009
commit 3b54760b51
3 changed files with 4430 additions and 4 deletions

4390
external/jshint.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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 ) {

View File

@ -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 ));