mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Build:Tests: Fix custom build tests, verify on Travis
This commit fixes unit tests for the following builds: 1. The no-deprecated build: `custom:-deprecated` 2. The current slim build: `custom:-ajax,-effects` 3. The future (#4553) slim build: `custom:-ajax,-callbacks,-deferred,-effects` It also adds separate Travis jobs for the no-deprecated & slim builds. Closes gh-4577
This commit is contained in:
parent
1dad1185e0
commit
0f780ba7cc
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,3 +21,4 @@ npm-debug.log*
|
||||
/node_modules
|
||||
|
||||
/test/data/core/jquery-iterability-transpiled.js
|
||||
/test/data/qunit-fixture.js
|
||||
|
14
.travis.yml
14
.travis.yml
@ -17,6 +17,20 @@ matrix:
|
||||
addons:
|
||||
chrome: stable
|
||||
firefox: latest
|
||||
# Run tests against the slim build.
|
||||
- node_js: "12"
|
||||
env:
|
||||
- NPM_SCRIPT="test:slim"
|
||||
- BROWSERS="ChromeHeadless"
|
||||
addons:
|
||||
chrome: stable
|
||||
# Run tests against the no-deprecated build.
|
||||
- node_js: "12"
|
||||
env:
|
||||
- NPM_SCRIPT="test:no-deprecated"
|
||||
- BROWSERS="ChromeHeadless"
|
||||
addons:
|
||||
chrome: stable
|
||||
# Run ES module tests.
|
||||
- node_js: "12"
|
||||
env:
|
||||
|
10
Gruntfile.js
10
Gruntfile.js
@ -41,7 +41,7 @@ module.exports = function( grunt ) {
|
||||
retainLines: true,
|
||||
plugins: [ "@babel/transform-for-of" ]
|
||||
},
|
||||
nodeSmokeTests: {
|
||||
tests: {
|
||||
files: {
|
||||
"test/data/core/jquery-iterability-transpiled.js":
|
||||
"test/data/core/jquery-iterability-transpiled-es6.js"
|
||||
@ -314,7 +314,13 @@ module.exports = function( grunt ) {
|
||||
"karma:jsdom"
|
||||
] );
|
||||
|
||||
grunt.registerTask( "test:prepare", [
|
||||
"qunit_fixture",
|
||||
"babel:tests"
|
||||
] );
|
||||
|
||||
grunt.registerTask( "test", [
|
||||
"test:prepare",
|
||||
"test:fast",
|
||||
"test:slow"
|
||||
] );
|
||||
@ -336,7 +342,7 @@ module.exports = function( grunt ) {
|
||||
"uglify",
|
||||
"remove_map_comment",
|
||||
"dist:*",
|
||||
"qunit_fixture",
|
||||
"test:prepare",
|
||||
"eslint:dist",
|
||||
"test:fast",
|
||||
"compare_size"
|
||||
|
@ -4,7 +4,7 @@ module.exports = ( grunt ) => {
|
||||
const fs = require( "fs" );
|
||||
const spawnTest = require( "./lib/spawn_test.js" );
|
||||
const testsDir = "./test/node_smoke_tests/";
|
||||
const nodeSmokeTests = [ "babel:nodeSmokeTests" ];
|
||||
const nodeSmokeTests = [];
|
||||
|
||||
// Fire up all tests defined in test/node_smoke_tests/*.js in spawned sub-processes.
|
||||
// All the files under test/node_smoke_tests/*.js are supposed to exit with 0 code
|
||||
|
@ -74,7 +74,9 @@
|
||||
"test:browser": "grunt && grunt karma:main",
|
||||
"test:esmodules": "grunt && grunt karma:esmodules",
|
||||
"test:amd": "grunt && grunt karma:amd",
|
||||
"test": "grunt && grunt test:slow && grunt karma:main && grunt karma:esmodules && grunt karma:amd",
|
||||
"test:no-deprecated": "grunt test:prepare && grunt custom:-deprecated && grunt karma:main",
|
||||
"test:slim": "grunt test:prepare && grunt custom:slim && grunt karma:main",
|
||||
"test": "npm run test:slim && npm run test:no-deprecated && grunt && grunt test:slow && grunt karma:main && grunt karma:esmodules && grunt karma:amd",
|
||||
"jenkins": "npm run test:browserless"
|
||||
},
|
||||
"commitplease": {
|
||||
|
@ -6,7 +6,7 @@ import nonce from "./ajax/var/nonce.js";
|
||||
import rquery from "./ajax/var/rquery.js";
|
||||
|
||||
import "./core/init.js";
|
||||
import "./ajax/parseXML.js";
|
||||
import "./core/parseXML.js";
|
||||
import "./event/trigger.js";
|
||||
import "./deferred.js";
|
||||
import "./serialize.js"; // jQuery.param
|
||||
|
3
src/jquery.js
vendored
3
src/jquery.js
vendored
@ -21,8 +21,9 @@ import "./ajax.js";
|
||||
import "./ajax/xhr.js";
|
||||
import "./ajax/script.js";
|
||||
import "./ajax/jsonp.js";
|
||||
import "./core/parseHTML.js";
|
||||
import "./ajax/load.js";
|
||||
import "./core/parseXML.js";
|
||||
import "./core/parseHTML.js";
|
||||
import "./event/ajax.js";
|
||||
import "./effects.js";
|
||||
import "./effects/animatedSelector.js";
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="../../jquery.js"></script>
|
||||
<script src="../jquery-1.9.1.js"></script>
|
||||
<script>var $j = jQuery.noConflict();</script>
|
||||
<script src="../iframeTest.js"></script>
|
||||
</head>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<script src="../iframeTest.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
jQuery( function( $ ) {
|
||||
$(".absolute").click(function() {
|
||||
$( ".absolute" ).on( "click", function() {
|
||||
$( "#marker" ).css( $( this ).offset() );
|
||||
var pos = $( this ).position();
|
||||
$( this ).css( { top: pos.top, left: pos.left } );
|
||||
|
@ -13,8 +13,8 @@
|
||||
<script src="../iframeTest.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
jQuery( function( $ ) {
|
||||
$("body").click(function() {
|
||||
$("marker").css( $(this).offset() );
|
||||
$( "body" ).on( "click", function() {
|
||||
$( "#marker" ).css( $( this ).offset() );
|
||||
return false;
|
||||
} );
|
||||
startIframeTest();
|
||||
|
@ -17,7 +17,7 @@
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
jQuery( function( $ ) {
|
||||
window.scrollTo( 1000, 1000 );
|
||||
$(".fixed").click(function() {
|
||||
$( ".fixed" ).on( "click", function() {
|
||||
$( "#marker" ).css( $( this ).offset() );
|
||||
return false;
|
||||
});
|
||||
|
@ -15,7 +15,7 @@
|
||||
<script src="../iframeTest.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
jQuery( function( $ ) {
|
||||
$(".relative").click(function() {
|
||||
$( ".relative" ).on( "click", function() {
|
||||
$( "#marker" ).css( $( this ).offset() );
|
||||
var pos = $( this ).position();
|
||||
$( this ).css( { position: 'absolute', top: pos.top, left: pos.left } );
|
||||
|
@ -21,7 +21,7 @@
|
||||
window.scrollTo( 1000, 1000 );
|
||||
$( "#scroll-1" )[ 0 ].scrollLeft = 5;
|
||||
$( "#scroll-1" )[ 0 ].scrollTop = 5;
|
||||
$(".scroll").click(function() {
|
||||
$( ".scroll" ).on( "click", function() {
|
||||
$( "#marker" ).css( $( this ).offset() );
|
||||
return false;
|
||||
} );
|
||||
|
@ -14,7 +14,7 @@
|
||||
<script src="../iframeTest.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
jQuery( function( $ ) {
|
||||
$(".static").click(function() {
|
||||
$( ".static" ).on( "click", function() {
|
||||
$( "#marker" ).css( $( this ).offset() );
|
||||
var pos = $( this ).position();
|
||||
$( this ).css( { position: 'absolute', top: pos.top, left: pos.left } );
|
||||
|
@ -14,7 +14,7 @@
|
||||
<script src="../iframeTest.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
jQuery( function( $ ) {
|
||||
$("table, th, td").click(function() {
|
||||
$( "table, th, td" ).on( "click", function() {
|
||||
$( "#marker" ).css( $( this ).offset() );
|
||||
return false;
|
||||
} );
|
||||
|
File diff suppressed because one or more lines are too long
@ -255,7 +255,7 @@ QUnit.module( "ajax", {
|
||||
ajaxTest( "jQuery.ajax() - headers", 8, function( assert ) {
|
||||
return {
|
||||
setup: function() {
|
||||
jQuery( document ).ajaxSend( function( evt, xhr ) {
|
||||
jQuery( document ).on( "ajaxSend", function( evt, xhr ) {
|
||||
xhr.setRequestHeader( "ajax-send", "test" );
|
||||
} );
|
||||
},
|
||||
@ -580,10 +580,10 @@ QUnit.module( "ajax", {
|
||||
return {
|
||||
setup: function() {
|
||||
jQuery( context ).appendTo( "#foo" )
|
||||
.ajaxSend( event )
|
||||
.ajaxComplete( event )
|
||||
.ajaxError( event )
|
||||
.ajaxSuccess( event );
|
||||
.on( "ajaxSend", event )
|
||||
.on( "ajaxComplete", event )
|
||||
.on( "ajaxError", event )
|
||||
.on( "ajaxSuccess", event );
|
||||
},
|
||||
requests: [ {
|
||||
url: url( "name.html" ),
|
||||
@ -2539,7 +2539,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
|
||||
var done = assert.async();
|
||||
|
||||
addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError", assert )();
|
||||
jQuery( document ).ajaxStop( done );
|
||||
jQuery( document ).on( "ajaxStop", done );
|
||||
jQuery( "<div/>" ).load( baseURL + "404.txt", function() {
|
||||
assert.ok( true, "complete" );
|
||||
} );
|
||||
@ -2727,7 +2727,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
|
||||
jQuery.ajaxSetup( {
|
||||
dataType: "json"
|
||||
} );
|
||||
jQuery( document ).ajaxComplete( function( e, xml, s ) {
|
||||
jQuery( document ).on( "ajaxComplete", function( e, xml, s ) {
|
||||
assert.strictEqual( s.dataType, "html", "Verify the load() dataType was html" );
|
||||
jQuery( document ).off( "ajaxComplete" );
|
||||
done();
|
||||
@ -2748,7 +2748,7 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
|
||||
}
|
||||
} );
|
||||
jQuery( "#foo" ).load( baseURL + "mock.php?action=echoQuery", data );
|
||||
jQuery( document ).ajaxComplete( function( event, jqXHR, options ) {
|
||||
jQuery( document ).on( "ajaxComplete", function( event, jqXHR, options ) {
|
||||
assert.ok( ~options.data.indexOf( "foo=bar" ), "Data from ajaxSettings was used" );
|
||||
done();
|
||||
} );
|
||||
|
@ -4,6 +4,12 @@ QUnit.module( "callbacks", {
|
||||
|
||||
( function() {
|
||||
|
||||
if ( !jQuery.Callbacks ) {
|
||||
return;
|
||||
}
|
||||
|
||||
( function() {
|
||||
|
||||
var output,
|
||||
addToOutput = function( string ) {
|
||||
return function() {
|
||||
@ -387,3 +393,5 @@ QUnit.test( "jQuery.Callbacks() - list with memory stays locked (gh-3469)", func
|
||||
cb.fire();
|
||||
assert.equal( fired, 11, "Post-lock() fire ignored" );
|
||||
} );
|
||||
|
||||
} )();
|
||||
|
@ -2,6 +2,12 @@ QUnit.module( "deferred", {
|
||||
afterEach: moduleTeardown
|
||||
} );
|
||||
|
||||
( function() {
|
||||
|
||||
if ( !jQuery.Deferred ) {
|
||||
return;
|
||||
}
|
||||
|
||||
jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
|
||||
function createDeferred( fn ) {
|
||||
@ -1111,3 +1117,5 @@ QUnit.test( "jQuery.when(...) - opportunistically synchronous", function( assert
|
||||
|
||||
when = "after";
|
||||
} );
|
||||
|
||||
} )();
|
||||
|
@ -1,7 +1,7 @@
|
||||
QUnit.module( "deprecated", { afterEach: moduleTeardown } );
|
||||
|
||||
|
||||
QUnit.test( "bind/unbind", function( assert ) {
|
||||
QUnit[ jQuery.fn.bind ? "test" : "skip" ]( "bind/unbind", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var markup = jQuery(
|
||||
@ -22,7 +22,7 @@ QUnit.test( "bind/unbind", function( assert ) {
|
||||
.remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "delegate/undelegate", function( assert ) {
|
||||
QUnit[ jQuery.fn.delegate ? "test" : "skip" ]( "delegate/undelegate", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var markup = jQuery(
|
||||
@ -95,6 +95,45 @@ QUnit[ jQuery.fn.click ? "test" : "skip" ]( "trigger() shortcuts", function( ass
|
||||
assert.equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
|
||||
} );
|
||||
|
||||
if ( jQuery.ajax && jQuery.fn.ajaxSend ) {
|
||||
ajaxTest( "jQuery.ajax() - events with context", 12, function( assert ) {
|
||||
var context = document.createElement( "div" );
|
||||
|
||||
function event( e ) {
|
||||
assert.equal( this, context, e.type );
|
||||
}
|
||||
|
||||
function callback( msg ) {
|
||||
return function() {
|
||||
assert.equal( this, context, "context is preserved on callback " + msg );
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
setup: function() {
|
||||
jQuery( context ).appendTo( "#foo" )
|
||||
.ajaxSend( event )
|
||||
.ajaxComplete( event )
|
||||
.ajaxError( event )
|
||||
.ajaxSuccess( event );
|
||||
},
|
||||
requests: [ {
|
||||
url: url( "name.html" ),
|
||||
context: context,
|
||||
beforeSend: callback( "beforeSend" ),
|
||||
success: callback( "success" ),
|
||||
complete: callback( "complete" )
|
||||
}, {
|
||||
url: url( "404.txt" ),
|
||||
context: context,
|
||||
beforeSend: callback( "beforeSend" ),
|
||||
error: callback( "error" ),
|
||||
complete: callback( "complete" )
|
||||
} ]
|
||||
};
|
||||
} );
|
||||
}
|
||||
|
||||
QUnit[ jQuery.fn.click ? "test" : "skip" ]( "Event aliases", function( assert ) {
|
||||
|
||||
// Explicitly skipping focus/blur events due to their flakiness
|
||||
@ -113,7 +152,7 @@ QUnit[ jQuery.fn.click ? "test" : "skip" ]( "Event aliases", function( assert )
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.proxy", function( assert ) {
|
||||
QUnit[ jQuery.proxy ? "test" : "skip" ]( "jQuery.proxy", function( assert ) {
|
||||
assert.expect( 9 );
|
||||
|
||||
var test2, test3, test4, fn, cb,
|
||||
@ -161,7 +200,7 @@ QUnit.test( "jQuery.proxy", function( assert ) {
|
||||
cb.call( thisObject, "arg3" );
|
||||
} );
|
||||
|
||||
QUnit.test( "trim", function( assert ) {
|
||||
QUnit[ jQuery.trim ? "test" : "skip" ]( "trim", function( assert ) {
|
||||
assert.expect( 13 );
|
||||
|
||||
var nbsp = String.fromCharCode( 160 );
|
||||
|
@ -1317,7 +1317,7 @@ QUnit.test( "Delegated events with malformed selectors (gh-3071)", function( ass
|
||||
jQuery( "#foo" ).on( "click", "nonexistent:not", function() {} );
|
||||
}, "short-circuitable malformed selector throws on attach" );
|
||||
|
||||
jQuery( "#foo > :first-child" ).click();
|
||||
jQuery( "#foo > :first-child" ).trigger( "click" );
|
||||
assert.ok( true, "malformed selector does not throw on event" );
|
||||
} );
|
||||
|
||||
@ -2495,7 +2495,7 @@ QUnit.test( "drag/drop events copy mouse-related event properties (gh-1925, gh-2
|
||||
|
||||
fireNative( $fixture[ 0 ], "drop" );
|
||||
|
||||
$fixture.unbind( "dragmove drop" ).remove();
|
||||
$fixture.off( "dragmove drop" ).remove();
|
||||
} );
|
||||
|
||||
QUnit.test( "focusin using non-element targets", function( assert ) {
|
||||
@ -2548,7 +2548,8 @@ testIframe(
|
||||
function( assert, jQuery, window, document, isOk ) {
|
||||
assert.expect( 1 );
|
||||
assert.ok( isOk, "$.when( $.ready ) works" );
|
||||
}
|
||||
},
|
||||
jQuery.when ? QUnit.test : QUnit.skip
|
||||
);
|
||||
|
||||
// need PHP here to make the incepted IFRAME hang
|
||||
|
@ -2400,7 +2400,6 @@ QUnit.test( "html() - script exceptions bubble (#11743)", function( assert ) {
|
||||
assert.ok( true, "Exception ignored" );
|
||||
} else {
|
||||
assert.ok( true, "No jQuery.ajax" );
|
||||
assert.ok( true, "No jQuery.ajax" );
|
||||
}
|
||||
};
|
||||
|
||||
@ -2490,7 +2489,7 @@ QUnit.test( "script evaluation (#11795)", function( assert ) {
|
||||
}
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery._evalUrl (#12838)", function( assert ) {
|
||||
QUnit[ jQuery.ajax ? "test" : "skip" ]( "jQuery._evalUrl (#12838)", function( assert ) {
|
||||
|
||||
assert.expect( 5 );
|
||||
|
||||
@ -2788,7 +2787,8 @@ QUnit.test( "Make sure tags with single-character names are found (gh-4124)", fu
|
||||
assert.strictEqual( htmlOut, htmlIn );
|
||||
} );
|
||||
|
||||
QUnit.test( "Insert script with data-URI (gh-1887)", function( assert ) {
|
||||
// The AJAX module is needed for jQuery._evalUrl.
|
||||
QUnit[ jQuery.ajax ? "test" : "skip" ]( "Insert script with data-URI (gh-1887)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
Globals.register( "testFoo" );
|
||||
@ -2869,10 +2869,11 @@ testIframe(
|
||||
} );
|
||||
},
|
||||
|
||||
// The AJAX module is needed for jQuery._evalUrl.
|
||||
// Support: Edge <=18+
|
||||
// Edge doesn't support nonce in non-inline scripts.
|
||||
// See https://web.archive.org/web/20171203124125/https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13246371/
|
||||
QUnit[ /\bedge\//i.test( navigator.userAgent ) ? "skip" : "test" ]
|
||||
QUnit[ jQuery.ajax && !/\bedge\//i.test( navigator.userAgent ) ? "test" : "skip" ]
|
||||
);
|
||||
|
||||
testIframe(
|
||||
|
@ -1,5 +1,11 @@
|
||||
QUnit.module( "queue", { afterEach: moduleTeardown } );
|
||||
|
||||
( function() {
|
||||
|
||||
if ( !jQuery.fn.queue ) {
|
||||
return;
|
||||
}
|
||||
|
||||
QUnit.test( "queue() with other types", function( assert ) {
|
||||
var done = assert.async( 2 );
|
||||
assert.expect( 14 );
|
||||
@ -329,3 +335,5 @@ QUnit[ jQuery.fn.stop ? "test" : "skip" ]( "queue stop hooks", function( assert
|
||||
|
||||
foo.stop( false, true );
|
||||
} );
|
||||
|
||||
} )();
|
||||
|
@ -2,7 +2,7 @@ QUnit.module( "ready" );
|
||||
|
||||
( function() {
|
||||
var notYetReady, noEarlyExecution,
|
||||
whenified = jQuery.when( jQuery.ready ),
|
||||
whenified = jQuery.when && jQuery.when( jQuery.ready ),
|
||||
promisified = Promise.resolve( jQuery.ready ),
|
||||
start = new Date(),
|
||||
order = [],
|
||||
@ -105,7 +105,7 @@ QUnit.module( "ready" );
|
||||
} );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.when(jQuery.ready)", function( assert ) {
|
||||
QUnit[ jQuery.when ? "test" : "skip" ]( "jQuery.when(jQuery.ready)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var done = jQuery.map( new Array( 2 ), function() { return assert.async(); } );
|
||||
|
||||
@ -149,6 +149,8 @@ QUnit.module( "ready" );
|
||||
} );
|
||||
} );
|
||||
|
||||
// jQuery.holdReady is deprecated, skip the test if it was excluded.
|
||||
if ( jQuery.holdReady ) {
|
||||
testIframe(
|
||||
"holdReady test needs to be a standalone test since it deals with DOM ready",
|
||||
"readywait.html",
|
||||
@ -159,5 +161,6 @@ QUnit.module( "ready" );
|
||||
assert.ok( releaseCalled, "The release function was called, which resulted in ready" );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
} )();
|
||||
|
@ -77,7 +77,7 @@ QUnit.test( "jQuery.param()", function( assert ) {
|
||||
assert.equal( jQuery.param( params ), "", "jQuery.param( undefined ) === empty string" );
|
||||
} );
|
||||
|
||||
QUnit.test( "jQuery.param() not affected by ajaxSettings", function( assert ) {
|
||||
QUnit[ jQuery.ajax ? "test" : "skip" ]( "jQuery.param() not affected by ajaxSettings", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var oldTraditional = jQuery.ajaxSettings.traditional;
|
||||
|
Loading…
Reference in New Issue
Block a user