Utilize the assert module, avoid inline JSHint comments.
fs.readdirSync( testsDir )
.filter( function( testFilePath ) {
- return fs.statSync( testsDir + testFilePath ).isFile();
+ return fs.statSync( testsDir + testFilePath ).isFile() &&
+ /\.js$/.test( testFilePath );
} )
.forEach( function( testFilePath ) {
var taskName = "node_" + testFilePath.replace( /\.js$/, "" );
--- /dev/null
+{
+ "boss": true,
+ "curly": true,
+ "eqeqeq": true,
+ "eqnull": true,
+ "expr": true,
+ "immed": true,
+ "noarg": true,
+ "quotmark": "double",
+ "undef": true,
+ "unused": true,
+
+ "node": true
+}
-/* jshint node: true */
-
"use strict";
-var ensureGlobalNotCreated = require( "./lib/ensure_global_not_created" ),
+var assert = require( "assert" ),
+ ensureGlobalNotCreated = require( "./lib/ensure_global_not_created" ),
jQueryFactory = require( "../../dist/jquery.js" );
-try {
+assert.throws( function () {
jQueryFactory( {} );
- console.error( "The jQuery factory should reject window without a document" );
- process.exit( 1 );
-} catch ( e ) {
- if ( e.message === "jQuery requires a window with a document" ) {
- ensureGlobalNotCreated( module.exports );
- process.exit( 0 );
- }
- console.error( "An unexpected error thrown; message: ", e.message );
- process.exit( 1 );
-}
+}, /jQuery requires a window with a document/ );
+
+ensureGlobalNotCreated( module.exports );
-/* jshint node: true */
-
"use strict";
+var assert = require( "assert" );
+
require( "jsdom" ).env( "", function( errors, window ) {
- if ( errors ) {
- console.error( errors );
- process.exit( 1 );
- }
+ assert.ifError( errors );
var ensureJQuery = require( "./lib/ensure_jquery" ),
ensureGlobalNotCreated = require( "./lib/ensure_global_not_created" ),
-/* jshint node: true */
-
"use strict";
+var assert = require( "assert" );
+
require( "jsdom" ).env( "", function( errors, window ) {
- if ( errors ) {
- console.error( errors );
- process.exit( 1 );
- }
+ assert.ifError( errors );
// Pretend the window is a global.
global.window = window;
-/* jshint node: true */
-
"use strict";
+var assert = require( "assert" );
+
// Ensure the jQuery property on global/window/module.exports/etc. was not
// created in a CommonJS environment.
// `global` is always checked in addition to passed parameters.
var args = [].slice.call( arguments ).concat( global );
args.forEach( function( object ) {
- if ( object.jQuery ) {
- console.error( "A jQuery global was created in a CommonJS environment." );
- process.exit( 1 );
- }
+ assert.strictEqual( object.jQuery, undefined,
+ "A jQuery global was created in a CommonJS environment." );
} );
};
-/* jshint node: true */
-
"use strict";
+var assert = require( "assert" );
+
// Check if the object we got is the jQuery object by invoking a basic API.
module.exports = function ensureJQuery( jQuery ) {
- if ( !/^jQuery/.test( jQuery.expando ) ) {
- console.error( "jQuery.expando was not detected, the jQuery bootstrap process has failed" );
- process.exit( 1 );
- }
+ assert( /^jQuery/.test( jQuery.expando ),
+ "jQuery.expando was not detected, the jQuery bootstrap process has failed" );
};