Commit 57652eec authored by Timmy Willison's avatar Timmy Willison

Build: fix tests in AMD mode

parent 828a718a
...@@ -26,7 +26,7 @@ module.exports = function( grunt ) { ...@@ -26,7 +26,7 @@ module.exports = function( grunt ) {
skipSemiColonInsertion: true, skipSemiColonInsertion: true,
wrap: { wrap: {
startFile: "src/intro.js", startFile: "src/intro.js",
endFile: "src/outro.js" endFile: [ "src/exports/global.js", "src/outro.js" ]
}, },
paths: { paths: {
sizzle: "../external/sizzle/dist/sizzle" sizzle: "../external/sizzle/dist/sizzle"
...@@ -61,13 +61,10 @@ module.exports = function( grunt ) { ...@@ -61,13 +61,10 @@ module.exports = function( grunt ) {
} else { } else {
// Ignore jQuery's exports (the only necessary one) contents = contents
if ( name !== "jquery" ) { .replace( /\s*return\s+[^\}]+(\}\);[^\w\}]*)$/, "$1" )
contents = contents // Multiple exports
.replace( /\s*return\s+[^\}]+(\}\);[^\w\}]*)$/, "$1" ) .replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
// Multiple exports
.replace( /\s*exports\.\w+\s*=\s*\w+;/g, "" );
}
// Remove define wrappers, closure ends, and empty declarations // Remove define wrappers, closure ends, and empty declarations
contents = contents contents = contents
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
"globals": { "globals": {
"jQuery": true, "jQuery": true,
"define": true, "define": false,
"module": true "module": false,
"noGlobal": true
} }
} }
define([
"../core"
], function( jQuery ) {
var var
// Map over jQuery in case of overwrite // Map over jQuery in case of overwrite
_jQuery = window.jQuery, _jQuery = window.jQuery,
...@@ -24,8 +20,6 @@ jQuery.noConflict = function( deep ) { ...@@ -24,8 +20,6 @@ jQuery.noConflict = function( deep ) {
// Expose jQuery and $ identifiers, even in // Expose jQuery and $ identifiers, even in
// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566) // and CommonJS for browser emulators (#13566)
if ( typeof noGlobal === "undefined" ) { if ( !noGlobal ) {
window.jQuery = window.$ = jQuery; window.jQuery = window.$ = jQuery;
} }
});
...@@ -29,10 +29,9 @@ define([ ...@@ -29,10 +29,9 @@ define([
"./offset", "./offset",
"./dimensions", "./dimensions",
"./deprecated", "./deprecated",
"./exports/amd", "./exports/amd"
"./exports/global"
], function( jQuery ) { ], function( jQuery ) {
return jQuery; return (window.jQuery = window.$ = jQuery);
}); });
return jQuery;
})); }));
...@@ -304,7 +304,9 @@ this.loadTests = function() { ...@@ -304,7 +304,9 @@ this.loadTests = function() {
/** /**
* Run in noConflict mode * Run in noConflict mode
*/ */
jQuery.noConflict(); if ( jQuery.noConflict ) {
jQuery.noConflict();
}
// Load the TestSwarm listener if swarmURL is in the address. // Load the TestSwarm listener if swarmURL is in the address.
if ( loadSwarm ) { if ( loadSwarm ) {
......
...@@ -226,24 +226,27 @@ test( "globalEval execution after script injection (#7862)", 1, function() { ...@@ -226,24 +226,27 @@ test( "globalEval execution after script injection (#7862)", 1, function() {
ok( window.strictEvalTest - now < 500, "Code executed synchronously" ); ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
}); });
test("noConflict", function() { // This is not run in AMD mode
expect(7); if ( jQuery.noConflict ) {
test("noConflict", function() {
expect(7);
var $$ = jQuery; var $$ = jQuery;
strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" ); strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );
strictEqual( window["jQuery"], $$, "Make sure jQuery wasn't touched." ); strictEqual( window["jQuery"], $$, "Make sure jQuery wasn't touched." );
strictEqual( window["$"], original$, "Make sure $ was reverted." ); strictEqual( window["$"], original$, "Make sure $ was reverted." );
jQuery = $ = $$; jQuery = $ = $$;
strictEqual( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" ); strictEqual( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
strictEqual( window["jQuery"], originaljQuery, "Make sure jQuery was reverted." ); strictEqual( window["jQuery"], originaljQuery, "Make sure jQuery was reverted." );
strictEqual( window["$"], original$, "Make sure $ was reverted." ); strictEqual( window["$"], original$, "Make sure $ was reverted." );
ok( $$().pushStack([]), "Make sure that jQuery still works." ); ok( $$().pushStack([]), "Make sure that jQuery still works." );
window["jQuery"] = jQuery = $$; window["jQuery"] = jQuery = $$;
}); });
}
test("trim", function() { test("trim", function() {
expect(13); expect(13);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment