mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Tests: partially use new qunit interface
http://qunitjs.com/upgrade-guide-2.x/ For most of the boring work was used https://github.com/apsdehal/qunit-migrate package However, it can't update local qunit helpers, plus in some places old QUnit.asyncTest signature is still used Fixes gh-2540
This commit is contained in:
parent
9d820fbde6
commit
b930d14ce6
@ -137,16 +137,20 @@ function url( value ) {
|
||||
|
||||
// Ajax testing helper
|
||||
this.ajaxTest = function( title, expect, options ) {
|
||||
var requestOptions;
|
||||
if ( jQuery.isFunction( options ) ) {
|
||||
options = options();
|
||||
}
|
||||
options = options || [];
|
||||
requestOptions = options.requests || options.request || options;
|
||||
if ( !jQuery.isArray( requestOptions ) ) {
|
||||
requestOptions = [ requestOptions ];
|
||||
}
|
||||
asyncTest( title, expect, function() {
|
||||
QUnit.test( title, expect, function( assert ) {
|
||||
var requestOptions;
|
||||
|
||||
if ( jQuery.isFunction( options ) ) {
|
||||
options = options( assert );
|
||||
}
|
||||
options = options || [];
|
||||
requestOptions = options.requests || options.request || options;
|
||||
if ( !jQuery.isArray( requestOptions ) ) {
|
||||
requestOptions = [ requestOptions ];
|
||||
}
|
||||
|
||||
var done = assert.async();
|
||||
|
||||
if ( options.setup ) {
|
||||
options.setup();
|
||||
}
|
||||
@ -160,7 +164,9 @@ this.ajaxTest = function( title, expect, options ) {
|
||||
if ( options.teardown ) {
|
||||
options.teardown();
|
||||
}
|
||||
start();
|
||||
|
||||
// Make sure all events will be called before done()
|
||||
setTimeout(done);
|
||||
}
|
||||
},
|
||||
requests = jQuery.map( requestOptions, function( options ) {
|
||||
@ -170,7 +176,7 @@ this.ajaxTest = function( title, expect, options ) {
|
||||
return function( _, status ) {
|
||||
if ( !completed ) {
|
||||
if ( !handler ) {
|
||||
ok( false, "unexpected " + status );
|
||||
assert.ok( false, "unexpected " + status );
|
||||
} else if ( jQuery.isFunction( handler ) ) {
|
||||
handler.apply( this, arguments );
|
||||
}
|
||||
@ -179,7 +185,7 @@ this.ajaxTest = function( title, expect, options ) {
|
||||
};
|
||||
|
||||
if ( options.afterSend ) {
|
||||
options.afterSend( request );
|
||||
options.afterSend( request, assert );
|
||||
}
|
||||
|
||||
return request
|
||||
@ -202,7 +208,8 @@ this.ajaxTest = function( title, expect, options ) {
|
||||
};
|
||||
|
||||
this.testIframe = function( fileName, name, fn ) {
|
||||
asyncTest(name, function() {
|
||||
QUnit.test(name, function( assert ) {
|
||||
var done = assert.async();
|
||||
|
||||
// load fixture in iframe
|
||||
var iframe = loadFixture(),
|
||||
@ -211,10 +218,9 @@ this.testIframe = function( fileName, name, fn ) {
|
||||
if ( win && win.jQuery && win.jQuery.isReady ) {
|
||||
clearInterval( interval );
|
||||
|
||||
start();
|
||||
|
||||
// call actual tests passing the correct jQuery instance to use
|
||||
fn.call( this, win.jQuery, win, win.document );
|
||||
fn.call( this, win.jQuery, win, win.document, assert );
|
||||
done();
|
||||
document.body.removeChild( iframe );
|
||||
iframe = null;
|
||||
}
|
||||
@ -233,11 +239,14 @@ this.testIframe = function( fileName, name, fn ) {
|
||||
};
|
||||
|
||||
this.testIframeWithCallback = function( title, fileName, func ) {
|
||||
asyncTest( title, 1, function() {
|
||||
QUnit.test( title, 1, function( assert ) {
|
||||
var iframe;
|
||||
var done = assert.async();
|
||||
|
||||
window.iframeCallback = function() {
|
||||
var args = arguments;
|
||||
var args = Array.prototype.slice.call( arguments );
|
||||
|
||||
args.push( assert );
|
||||
|
||||
setTimeout(function() {
|
||||
this.iframeCallback = undefined;
|
||||
@ -246,7 +255,7 @@ this.testIframeWithCallback = function( title, fileName, func ) {
|
||||
func.apply( this, args );
|
||||
func = function() {};
|
||||
|
||||
start();
|
||||
done();
|
||||
});
|
||||
};
|
||||
iframe = jQuery( "<div/>" ).css({ position: "absolute", width: "500px", left: "-600px" })
|
||||
|
2442
test/unit/ajax.js
2442
test/unit/ajax.js
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ var oldRaf = window.requestAnimationFrame,
|
||||
startTime = 505877050;
|
||||
|
||||
// This module tests jQuery.Animation and the corresponding 1.8+ effects APIs
|
||||
module( "animation", {
|
||||
QUnit.module( "animation", {
|
||||
setup: function() {
|
||||
window.requestAnimationFrame = null;
|
||||
this.sandbox = sinon.sandbox.create();
|
||||
@ -33,77 +33,93 @@ module( "animation", {
|
||||
}
|
||||
} );
|
||||
|
||||
test( "Animation( subject, props, opts ) - shape", function() {
|
||||
expect( 20 );
|
||||
QUnit.test( "Animation( subject, props, opts ) - shape", function( assert ) {
|
||||
assert.expect( 20 );
|
||||
|
||||
var subject = { test: 0 },
|
||||
props = { test: 1 },
|
||||
opts = { queue: "fx", duration: 100 },
|
||||
animation = jQuery.Animation( subject, props, opts );
|
||||
|
||||
equal( animation.elem, subject, ".elem is set to the exact object passed" );
|
||||
equal( animation.originalOptions, opts, ".originalOptions is set to options passed" );
|
||||
equal( animation.originalProperties, props, ".originalProperties is set to props passed" );
|
||||
assert.equal(
|
||||
animation.elem,
|
||||
subject,
|
||||
".elem is set to the exact object passed"
|
||||
);
|
||||
assert.equal(
|
||||
animation.originalOptions,
|
||||
opts,
|
||||
".originalOptions is set to options passed"
|
||||
);
|
||||
assert.equal(
|
||||
animation.originalProperties,
|
||||
props,
|
||||
".originalProperties is set to props passed"
|
||||
);
|
||||
|
||||
notEqual( animation.props, props, ".props is not the original however" );
|
||||
deepEqual( animation.props, props, ".props is a copy of the original" );
|
||||
assert.notEqual( animation.props, props, ".props is not the original however" );
|
||||
assert.deepEqual( animation.props, props, ".props is a copy of the original" );
|
||||
|
||||
deepEqual( animation.opts, {
|
||||
assert.deepEqual( animation.opts, {
|
||||
duration: 100,
|
||||
queue: "fx",
|
||||
specialEasing: { test: undefined },
|
||||
easing: jQuery.easing._default
|
||||
}, ".options is filled with default easing and specialEasing" );
|
||||
|
||||
equal( animation.startTime, startTime, "startTime was set" );
|
||||
equal( animation.duration, 100, ".duration is set" );
|
||||
assert.equal( animation.startTime, startTime, "startTime was set" );
|
||||
assert.equal( animation.duration, 100, ".duration is set" );
|
||||
|
||||
equal( animation.tweens.length, 1, ".tweens has one Tween" );
|
||||
equal( typeof animation.tweens[ 0 ].run, "function", "which has a .run function" );
|
||||
assert.equal( animation.tweens.length, 1, ".tweens has one Tween" );
|
||||
assert.equal( typeof animation.tweens[ 0 ].run, "function", "which has a .run function" );
|
||||
|
||||
equal( typeof animation.createTween, "function", ".createTween is a function" );
|
||||
equal( typeof animation.stop, "function", ".stop is a function" );
|
||||
assert.equal( typeof animation.createTween, "function", ".createTween is a function" );
|
||||
assert.equal( typeof animation.stop, "function", ".stop is a function" );
|
||||
|
||||
equal( typeof animation.done, "function", ".done is a function" );
|
||||
equal( typeof animation.fail, "function", ".fail is a function" );
|
||||
equal( typeof animation.always, "function", ".always is a function" );
|
||||
equal( typeof animation.progress, "function", ".progress is a function" );
|
||||
assert.equal( typeof animation.done, "function", ".done is a function" );
|
||||
assert.equal( typeof animation.fail, "function", ".fail is a function" );
|
||||
assert.equal( typeof animation.always, "function", ".always is a function" );
|
||||
assert.equal( typeof animation.progress, "function", ".progress is a function" );
|
||||
|
||||
equal( jQuery.timers.length, 1, "Added a timers function" );
|
||||
equal( jQuery.timers[ 0 ].elem, subject, "...with .elem as the subject" );
|
||||
equal( jQuery.timers[ 0 ].anim, animation, "...with .anim as the animation" );
|
||||
equal( jQuery.timers[ 0 ].queue, opts.queue, "...with .queue" );
|
||||
assert.equal( jQuery.timers.length, 1, "Added a timers function" );
|
||||
assert.equal( jQuery.timers[ 0 ].elem, subject, "...with .elem as the subject" );
|
||||
assert.equal( jQuery.timers[ 0 ].anim, animation, "...with .anim as the animation" );
|
||||
assert.equal( jQuery.timers[ 0 ].queue, opts.queue, "...with .queue" );
|
||||
|
||||
// Cleanup after ourselves by ticking to the end
|
||||
this.clock.tick( 100 );
|
||||
} );
|
||||
|
||||
test( "Animation.prefilter( fn ) - calls prefilter after defaultPrefilter", function() {
|
||||
expect( 1 );
|
||||
QUnit.test( "Animation.prefilter( fn ) - calls prefilter after defaultPrefilter",
|
||||
function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var prefilter = this.sandbox.stub(),
|
||||
defaultSpy = this.sandbox.spy( jQuery.Animation.prefilters, 0 );
|
||||
var prefilter = this.sandbox.stub(),
|
||||
defaultSpy = this.sandbox.spy( jQuery.Animation.prefilters, 0 );
|
||||
|
||||
jQuery.Animation.prefilter( prefilter );
|
||||
jQuery.Animation.prefilter( prefilter );
|
||||
|
||||
jQuery.Animation( {}, {}, {} );
|
||||
ok( prefilter.calledAfter( defaultSpy ), "our prefilter called after" );
|
||||
} );
|
||||
jQuery.Animation( {}, {}, {} );
|
||||
assert.ok( prefilter.calledAfter( defaultSpy ), "our prefilter called after" );
|
||||
}
|
||||
);
|
||||
|
||||
test( "Animation.prefilter( fn, true ) - calls prefilter before defaultPrefilter", function() {
|
||||
expect( 1 );
|
||||
QUnit.test( "Animation.prefilter( fn, true ) - calls prefilter before defaultPrefilter",
|
||||
function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var prefilter = this.sandbox.stub(),
|
||||
defaultSpy = this.sandbox.spy( jQuery.Animation.prefilters, 0 );
|
||||
var prefilter = this.sandbox.stub(),
|
||||
defaultSpy = this.sandbox.spy( jQuery.Animation.prefilters, 0 );
|
||||
|
||||
jQuery.Animation.prefilter( prefilter, true );
|
||||
jQuery.Animation.prefilter( prefilter, true );
|
||||
|
||||
jQuery.Animation( {}, {}, {} );
|
||||
ok( prefilter.calledBefore( defaultSpy ), "our prefilter called before" );
|
||||
} );
|
||||
jQuery.Animation( {}, {}, {} );
|
||||
assert.ok( prefilter.calledBefore( defaultSpy ), "our prefilter called before" );
|
||||
}
|
||||
);
|
||||
|
||||
test( "Animation.prefilter - prefilter return hooks", function() {
|
||||
expect( 34 );
|
||||
QUnit.test( "Animation.prefilter - prefilter return hooks", function( assert ) {
|
||||
assert.expect( 34 );
|
||||
|
||||
var animation, realAnimation, element,
|
||||
sandbox = this.sandbox,
|
||||
@ -115,10 +131,10 @@ test( "Animation.prefilter - prefilter return hooks", function() {
|
||||
realAnimation = this;
|
||||
sandbox.spy( realAnimation, "createTween" );
|
||||
|
||||
deepEqual( realAnimation.originalProperties, props, "originalProperties" );
|
||||
equal( arguments[ 0 ], this.elem, "first param elem" );
|
||||
equal( arguments[ 1 ], this.props, "second param props" );
|
||||
equal( arguments[ 2 ], this.opts, "third param opts" );
|
||||
assert.deepEqual( realAnimation.originalProperties, props, "originalProperties" );
|
||||
assert.equal( arguments[ 0 ], this.elem, "first param elem" );
|
||||
assert.equal( arguments[ 1 ], this.props, "second param props" );
|
||||
assert.equal( arguments[ 2 ], this.opts, "third param opts" );
|
||||
return ourAnimation;
|
||||
} ),
|
||||
defaultSpy = sandbox.spy( jQuery.Animation.prefilters, 0 ),
|
||||
@ -133,14 +149,25 @@ test( "Animation.prefilter - prefilter return hooks", function() {
|
||||
|
||||
animation = jQuery.Animation( target, props, opts );
|
||||
|
||||
equal( prefilter.callCount, 1, "Called prefilter" );
|
||||
assert.equal( prefilter.callCount, 1, "Called prefilter" );
|
||||
|
||||
equal( defaultSpy.callCount, 0,
|
||||
"Returning something from a prefilter caused remaining prefilters to not run" );
|
||||
equal( jQuery.fx.timer.callCount, 0, "Returning something never queues a timer" );
|
||||
equal( animation, ourAnimation, "Returning something returned it from jQuery.Animation" );
|
||||
equal( realAnimation.createTween.callCount, 0, "Returning something never creates tweens" );
|
||||
equal( TweenSpy.callCount, 0, "Returning something never creates tweens" );
|
||||
assert.equal(
|
||||
defaultSpy.callCount,
|
||||
0,
|
||||
"Returning something from a prefilter caused remaining prefilters to not run"
|
||||
);
|
||||
assert.equal( jQuery.fx.timer.callCount, 0, "Returning something never queues a timer" );
|
||||
assert.equal(
|
||||
animation,
|
||||
ourAnimation,
|
||||
"Returning something returned it from jQuery.Animation"
|
||||
);
|
||||
assert.equal(
|
||||
realAnimation.createTween.callCount,
|
||||
0,
|
||||
"Returning something never creates tweens"
|
||||
);
|
||||
assert.equal( TweenSpy.callCount, 0, "Returning something never creates tweens" );
|
||||
|
||||
// Test overriden usage on queues:
|
||||
prefilter.reset();
|
||||
@ -153,78 +180,84 @@ test( "Animation.prefilter - prefilter return hooks", function() {
|
||||
.animate( props, 100 )
|
||||
.queue( queueSpy );
|
||||
|
||||
equal( prefilter.callCount, 1, "Called prefilter" );
|
||||
equal( queueSpy.callCount, 0, "Next function in queue not called" );
|
||||
assert.equal( prefilter.callCount, 1, "Called prefilter" );
|
||||
assert.equal( queueSpy.callCount, 0, "Next function in queue not called" );
|
||||
|
||||
realAnimation.opts.complete.call( realAnimation.elem );
|
||||
equal( queueSpy.callCount, 1, "Next function in queue called after complete" );
|
||||
assert.equal( queueSpy.callCount, 1, "Next function in queue called after complete" );
|
||||
|
||||
equal( prefilter.callCount, 2, "Called prefilter again - animation #2" );
|
||||
equal( ourAnimation.stop.callCount, 0, ".stop() on our animation hasn't been called" );
|
||||
assert.equal( prefilter.callCount, 2, "Called prefilter again - animation #2" );
|
||||
assert.equal( ourAnimation.stop.callCount, 0, ".stop() on our animation hasn't been called" );
|
||||
|
||||
element.stop();
|
||||
equal( ourAnimation.stop.callCount, 1, ".stop() called ourAnimation.stop()" );
|
||||
ok( !ourAnimation.stop.args[ 0 ][ 0 ], ".stop( falsy ) (undefined or false are both valid)" );
|
||||
assert.equal( ourAnimation.stop.callCount, 1, ".stop() called ourAnimation.stop()" );
|
||||
assert.ok(
|
||||
!ourAnimation.stop.args[ 0 ][ 0 ],
|
||||
".stop( falsy ) (undefined or false are both valid)"
|
||||
);
|
||||
|
||||
equal( queueSpy.callCount, 2, "Next queue function called" );
|
||||
ok( queueSpy.calledAfter( ourAnimation.stop ), "After our animation was told to stop" );
|
||||
assert.equal( queueSpy.callCount, 2, "Next queue function called" );
|
||||
assert.ok( queueSpy.calledAfter( ourAnimation.stop ), "After our animation was told to stop" );
|
||||
|
||||
// ourAnimation.stop.reset();
|
||||
equal( prefilter.callCount, 3, "Got the next animation" );
|
||||
assert.equal( prefilter.callCount, 3, "Got the next animation" );
|
||||
|
||||
ourAnimation.stop.reset();
|
||||
|
||||
// do not clear queue, gotoEnd
|
||||
element.stop( false, true );
|
||||
ok( ourAnimation.stop.calledWith( true ), ".stop(true) calls .stop(true)" );
|
||||
ok( queueSpy.calledAfter( ourAnimation.stop ),
|
||||
assert.ok( ourAnimation.stop.calledWith( true ), ".stop(true) calls .stop(true)" );
|
||||
assert.ok( queueSpy.calledAfter( ourAnimation.stop ),
|
||||
"and the next queue function ran after we were told" );
|
||||
} );
|
||||
|
||||
test( "Animation.tweener( fn ) - unshifts a * tweener", function() {
|
||||
expect( 2 );
|
||||
QUnit.test( "Animation.tweener( fn ) - unshifts a * tweener", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var starTweeners = jQuery.Animation.tweeners[ "*" ];
|
||||
|
||||
jQuery.Animation.tweener( jQuery.noop );
|
||||
equal( starTweeners.length, 2 );
|
||||
deepEqual( starTweeners, [ jQuery.noop, defaultTweener ] );
|
||||
assert.equal( starTweeners.length, 2 );
|
||||
assert.deepEqual( starTweeners, [ jQuery.noop, defaultTweener ] );
|
||||
} );
|
||||
|
||||
test( "Animation.tweener( 'prop', fn ) - unshifts a 'prop' tweener", function() {
|
||||
expect( 4 );
|
||||
QUnit.test( "Animation.tweener( 'prop', fn ) - unshifts a 'prop' tweener", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
var tweeners = jQuery.Animation.tweeners,
|
||||
fn = function() {};
|
||||
|
||||
jQuery.Animation.tweener( "prop", jQuery.noop );
|
||||
equal( tweeners.prop.length, 1 );
|
||||
deepEqual( tweeners.prop, [ jQuery.noop ] );
|
||||
assert.equal( tweeners.prop.length, 1 );
|
||||
assert.deepEqual( tweeners.prop, [ jQuery.noop ] );
|
||||
|
||||
jQuery.Animation.tweener( "prop", fn );
|
||||
equal( tweeners.prop.length, 2 );
|
||||
deepEqual( tweeners.prop, [ fn, jQuery.noop ] );
|
||||
assert.equal( tweeners.prop.length, 2 );
|
||||
assert.deepEqual( tweeners.prop, [ fn, jQuery.noop ] );
|
||||
} );
|
||||
|
||||
test( "Animation.tweener( 'list of props', fn ) - unshifts a tweener to each prop", function() {
|
||||
expect( 2 );
|
||||
var tweeners = jQuery.Animation.tweeners,
|
||||
fn = function() {};
|
||||
QUnit.test(
|
||||
"Animation.tweener( 'list of props', fn ) - unshifts a tweener to each prop",
|
||||
function( assert ) {
|
||||
assert.expect( 2 );
|
||||
var tweeners = jQuery.Animation.tweeners,
|
||||
fn = function() {};
|
||||
|
||||
jQuery.Animation.tweener( "list of props", jQuery.noop );
|
||||
deepEqual( tweeners, {
|
||||
list: [ jQuery.noop ],
|
||||
of: [ jQuery.noop ],
|
||||
props: [ jQuery.noop ],
|
||||
"*": [ defaultTweener ]
|
||||
} );
|
||||
jQuery.Animation.tweener( "list of props", jQuery.noop );
|
||||
assert.deepEqual( tweeners, {
|
||||
list: [ jQuery.noop ],
|
||||
of: [ jQuery.noop ],
|
||||
props: [ jQuery.noop ],
|
||||
"*": [ defaultTweener ]
|
||||
} );
|
||||
|
||||
// Test with extra whitespaces
|
||||
jQuery.Animation.tweener( " list\t of \tprops\n*", fn );
|
||||
deepEqual( tweeners, {
|
||||
list: [ fn, jQuery.noop ],
|
||||
of: [ fn, jQuery.noop ],
|
||||
props: [ fn, jQuery.noop ],
|
||||
"*": [ fn, defaultTweener ]
|
||||
} );
|
||||
} );
|
||||
// Test with extra whitespaces
|
||||
jQuery.Animation.tweener( " list\t of \tprops\n*", fn );
|
||||
assert.deepEqual( tweeners, {
|
||||
list: [ fn, jQuery.noop ],
|
||||
of: [ fn, jQuery.noop ],
|
||||
props: [ fn, jQuery.noop ],
|
||||
"*": [ fn, defaultTweener ]
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
} )();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
module( "callbacks", {
|
||||
QUnit.module( "callbacks", {
|
||||
teardown: moduleTeardown
|
||||
});
|
||||
|
||||
@ -63,9 +63,9 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
"object": objectFlags
|
||||
}, function( flagsTypes, flags ) {
|
||||
|
||||
test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function() {
|
||||
QUnit.test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function( assert ) {
|
||||
|
||||
expect( 29 );
|
||||
assert.expect( 29 );
|
||||
|
||||
var cblist,
|
||||
results = resultString.split( /\s+/ );
|
||||
@ -73,32 +73,32 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
// Basic binding and firing
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
strictEqual( cblist.locked(), false, ".locked() initially false" );
|
||||
strictEqual( cblist.disabled(), false, ".disabled() initially false" );
|
||||
strictEqual( cblist.fired(), false, ".fired() initially false" );
|
||||
assert.strictEqual( cblist.locked(), false, ".locked() initially false" );
|
||||
assert.strictEqual( cblist.disabled(), false, ".disabled() initially false" );
|
||||
assert.strictEqual( cblist.fired(), false, ".fired() initially false" );
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
strictEqual( cblist.fired(), false, ".fired() still false after .add" );
|
||||
assert.strictEqual( cblist.fired(), false, ".fired() still false after .add" );
|
||||
cblist.fire( "A" );
|
||||
strictEqual( output, "XA", "Basic binding and firing" );
|
||||
strictEqual( cblist.fired(), true, ".fired() detects firing" );
|
||||
assert.strictEqual( output, "XA", "Basic binding and firing" );
|
||||
assert.strictEqual( cblist.fired(), true, ".fired() detects firing" );
|
||||
output = "X";
|
||||
cblist.disable();
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
strictEqual( output, "X", "Adding a callback after disabling" );
|
||||
assert.strictEqual( output, "X", "Adding a callback after disabling" );
|
||||
cblist.fire("A");
|
||||
strictEqual( output, "X", "Firing after disabling" );
|
||||
strictEqual( cblist.disabled(), true, ".disabled() becomes true" );
|
||||
strictEqual( cblist.locked(), true, "disabling locks" );
|
||||
assert.strictEqual( output, "X", "Firing after disabling" );
|
||||
assert.strictEqual( cblist.disabled(), true, ".disabled() becomes true" );
|
||||
assert.strictEqual( cblist.locked(), true, "disabling locks" );
|
||||
|
||||
// Emptying while firing (#13517)
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( cblist.empty );
|
||||
cblist.add( function() {
|
||||
ok( false, "not emptied" );
|
||||
assert.ok( false, "not emptied" );
|
||||
} );
|
||||
cblist.fire();
|
||||
|
||||
@ -106,7 +106,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add( cblist.disable );
|
||||
cblist.add( function() {
|
||||
ok( false, "not disabled" );
|
||||
assert.ok( false, "not disabled" );
|
||||
} );
|
||||
cblist.fire();
|
||||
|
||||
@ -114,18 +114,18 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
output = "X";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function() {
|
||||
equal( this, window, "Basic binding and firing (context)" );
|
||||
assert.equal( this, window, "Basic binding and firing (context)" );
|
||||
output += Array.prototype.join.call( arguments, "" );
|
||||
});
|
||||
cblist.fireWith( window, [ "A", "B" ] );
|
||||
strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
|
||||
assert.strictEqual( output, "XAB", "Basic binding and firing (arguments)" );
|
||||
|
||||
// fireWith with no arguments
|
||||
output = "";
|
||||
cblist = jQuery.Callbacks( flags );
|
||||
cblist.add(function() {
|
||||
equal( this, window, "fireWith with no arguments (context is window)" );
|
||||
strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
|
||||
assert.equal( this, window, "fireWith with no arguments (context is window)" );
|
||||
assert.strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" );
|
||||
});
|
||||
cblist.fireWith();
|
||||
|
||||
@ -135,7 +135,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
cblist.add( outputA, outputB, outputC );
|
||||
cblist.remove( outputB, outputC );
|
||||
cblist.fire();
|
||||
strictEqual( output, "XA", "Basic binding, removing and firing" );
|
||||
assert.strictEqual( output, "XA", "Basic binding, removing and firing" );
|
||||
|
||||
// Empty
|
||||
output = "X";
|
||||
@ -145,7 +145,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
cblist.add( outputC );
|
||||
cblist.empty();
|
||||
cblist.fire();
|
||||
strictEqual( output, "X", "Empty" );
|
||||
assert.strictEqual( output, "X", "Empty" );
|
||||
|
||||
// Locking
|
||||
output = "X";
|
||||
@ -161,8 +161,8 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
strictEqual( output, "X", "Lock early" );
|
||||
strictEqual( cblist.locked(), true, "Locking reflected in accessor" );
|
||||
assert.strictEqual( output, "X", "Lock early" );
|
||||
assert.strictEqual( cblist.locked(), true, "Locking reflected in accessor" );
|
||||
|
||||
// Locking while firing (gh-1990)
|
||||
output = "X";
|
||||
@ -172,7 +172,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
output += str;
|
||||
});
|
||||
cblist.fire( "A" );
|
||||
strictEqual( output, "XA", "Locking doesn't abort execution (gh-1990)" );
|
||||
assert.strictEqual( output, "XA", "Locking doesn't abort execution (gh-1990)" );
|
||||
|
||||
// Ordering
|
||||
output = "X";
|
||||
@ -182,7 +182,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
outputA();
|
||||
}, outputB );
|
||||
cblist.fire();
|
||||
strictEqual( output, results.shift(), "Proper ordering" );
|
||||
assert.strictEqual( output, results.shift(), "Proper ordering" );
|
||||
|
||||
// Add and fire again
|
||||
output = "X";
|
||||
@ -190,11 +190,11 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
cblist.add( outputC );
|
||||
outputA();
|
||||
}, outputB );
|
||||
strictEqual( output, results.shift(), "Add after fire" );
|
||||
assert.strictEqual( output, results.shift(), "Add after fire" );
|
||||
|
||||
output = "X";
|
||||
cblist.fire();
|
||||
strictEqual( output, results.shift(), "Fire again" );
|
||||
assert.strictEqual( output, results.shift(), "Fire again" );
|
||||
|
||||
// Multiple fire
|
||||
output = "X";
|
||||
@ -203,20 +203,20 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
output += str;
|
||||
});
|
||||
cblist.fire("A");
|
||||
strictEqual( output, "XA", "Multiple fire (first fire)" );
|
||||
assert.strictEqual( output, "XA", "Multiple fire (first fire)" );
|
||||
output = "X";
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (first new callback)" );
|
||||
output = "X";
|
||||
cblist.fire("B");
|
||||
strictEqual( output, results.shift(), "Multiple fire (second fire)" );
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (second fire)" );
|
||||
output = "X";
|
||||
cblist.add(function( str ) {
|
||||
output += str;
|
||||
});
|
||||
strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
|
||||
assert.strictEqual( output, results.shift(), "Multiple fire (second new callback)" );
|
||||
|
||||
// Return false
|
||||
output = "X";
|
||||
@ -224,12 +224,12 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
cblist.add( outputA, function() { return false; }, outputB );
|
||||
cblist.add( outputA );
|
||||
cblist.fire();
|
||||
strictEqual( output, results.shift(), "Callback returning false" );
|
||||
assert.strictEqual( output, results.shift(), "Callback returning false" );
|
||||
|
||||
// Add another callback (to control lists with memory do not fire anymore)
|
||||
output = "X";
|
||||
cblist.add( outputC );
|
||||
strictEqual( output, results.shift(), "Adding a callback after one returned false" );
|
||||
assert.strictEqual( output, results.shift(), "Adding a callback after one returned false" );
|
||||
|
||||
// Callbacks are not iterated
|
||||
output = "";
|
||||
@ -243,7 +243,7 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
cblist.add( handler );
|
||||
cblist.add( handler );
|
||||
cblist.fire();
|
||||
strictEqual( output, results.shift(), "No callback iteration" );
|
||||
assert.strictEqual( output, results.shift(), "No callback iteration" );
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -251,9 +251,9 @@ jQuery.each( tests, function( strFlags, resultString ) {
|
||||
|
||||
})();
|
||||
|
||||
test( "jQuery.Callbacks( options ) - options are copied", function() {
|
||||
QUnit.test( "jQuery.Callbacks( options ) - options are copied", function( assert ) {
|
||||
|
||||
expect( 1 );
|
||||
assert.expect( 1 );
|
||||
|
||||
var options = {
|
||||
"unique": true
|
||||
@ -261,16 +261,16 @@ test( "jQuery.Callbacks( options ) - options are copied", function() {
|
||||
cb = jQuery.Callbacks( options ),
|
||||
count = 0,
|
||||
fn = function() {
|
||||
ok( !( count++ ), "called once" );
|
||||
assert.ok( !( count++ ), "called once" );
|
||||
};
|
||||
options["unique"] = false;
|
||||
cb.add( fn, fn );
|
||||
cb.fire();
|
||||
});
|
||||
|
||||
test( "jQuery.Callbacks.fireWith - arguments are copied", function() {
|
||||
QUnit.test( "jQuery.Callbacks.fireWith - arguments are copied", function( assert ) {
|
||||
|
||||
expect( 1 );
|
||||
assert.expect( 1 );
|
||||
|
||||
var cb = jQuery.Callbacks("memory"),
|
||||
args = ["hello"];
|
||||
@ -279,28 +279,28 @@ test( "jQuery.Callbacks.fireWith - arguments are copied", function() {
|
||||
args[ 0 ] = "world";
|
||||
|
||||
cb.add(function( hello ) {
|
||||
strictEqual( hello, "hello", "arguments are copied internally" );
|
||||
assert.strictEqual( hello, "hello", "arguments are copied internally" );
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Callbacks.remove - should remove all instances", function() {
|
||||
QUnit.test( "jQuery.Callbacks.remove - should remove all instances", function( assert ) {
|
||||
|
||||
expect( 1 );
|
||||
assert.expect( 1 );
|
||||
|
||||
var cb = jQuery.Callbacks();
|
||||
|
||||
function fn() {
|
||||
ok( false, "function wasn't removed" );
|
||||
assert.ok( false, "function wasn't removed" );
|
||||
}
|
||||
|
||||
cb.add( fn, fn, function() {
|
||||
ok( true, "end of test" );
|
||||
assert.ok( true, "end of test" );
|
||||
}).remove( fn ).fire();
|
||||
});
|
||||
|
||||
test( "jQuery.Callbacks.has", function() {
|
||||
QUnit.test( "jQuery.Callbacks.has", function( assert ) {
|
||||
|
||||
expect( 13 );
|
||||
assert.expect( 13 );
|
||||
|
||||
var cb = jQuery.Callbacks();
|
||||
function getA() {
|
||||
@ -313,48 +313,48 @@ test( "jQuery.Callbacks.has", function() {
|
||||
return "C";
|
||||
}
|
||||
cb.add(getA, getB, getC);
|
||||
strictEqual( cb.has(), true, "No arguments to .has() returns whether callback function(s) are attached or not" );
|
||||
strictEqual( cb.has(getA), true, "Check if a specific callback function is in the Callbacks list" );
|
||||
assert.strictEqual( cb.has(), true, "No arguments to .has() returns whether callback function(s) are attached or not" );
|
||||
assert.strictEqual( cb.has(getA), true, "Check if a specific callback function is in the Callbacks list" );
|
||||
|
||||
cb.remove(getB);
|
||||
strictEqual( cb.has(getB), false, "Remove a specific callback function and make sure its no longer there" );
|
||||
strictEqual( cb.has(getA), true, "Remove a specific callback function and make sure other callback function is still there" );
|
||||
assert.strictEqual( cb.has(getB), false, "Remove a specific callback function and make sure its no longer there" );
|
||||
assert.strictEqual( cb.has(getA), true, "Remove a specific callback function and make sure other callback function is still there" );
|
||||
|
||||
cb.empty();
|
||||
strictEqual( cb.has(), false, "Empty list and make sure there are no callback function(s)" );
|
||||
strictEqual( cb.has(getA), false, "Check for a specific function in an empty() list" );
|
||||
assert.strictEqual( cb.has(), false, "Empty list and make sure there are no callback function(s)" );
|
||||
assert.strictEqual( cb.has(getA), false, "Check for a specific function in an empty() list" );
|
||||
|
||||
cb.add(getA, getB, function(){
|
||||
strictEqual( cb.has(), true, "Check if list has callback function(s) from within a callback function" );
|
||||
strictEqual( cb.has(getA), true, "Check if list has a specific callback from within a callback function" );
|
||||
assert.strictEqual( cb.has(), true, "Check if list has callback function(s) from within a callback function" );
|
||||
assert.strictEqual( cb.has(getA), true, "Check if list has a specific callback from within a callback function" );
|
||||
}).fire();
|
||||
|
||||
strictEqual( cb.has(), true, "Callbacks list has callback function(s) after firing" );
|
||||
assert.strictEqual( cb.has(), true, "Callbacks list has callback function(s) after firing" );
|
||||
|
||||
cb.disable();
|
||||
strictEqual( cb.has(), false, "disabled() list has no callback functions (returns false)" );
|
||||
strictEqual( cb.has(getA), false, "Check for a specific function in a disabled() list" );
|
||||
assert.strictEqual( cb.has(), false, "disabled() list has no callback functions (returns false)" );
|
||||
assert.strictEqual( cb.has(getA), false, "Check for a specific function in a disabled() list" );
|
||||
|
||||
cb = jQuery.Callbacks("unique");
|
||||
cb.add(getA);
|
||||
cb.add(getA);
|
||||
strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" );
|
||||
assert.strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" );
|
||||
cb.lock();
|
||||
strictEqual( cb.has(), false, "locked() list is empty and returns false" );
|
||||
assert.strictEqual( cb.has(), false, "locked() list is empty and returns false" );
|
||||
});
|
||||
|
||||
test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function() {
|
||||
QUnit.test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function( assert ) {
|
||||
|
||||
expect( 1 );
|
||||
assert.expect( 1 );
|
||||
|
||||
jQuery.Callbacks().add( "hello world" );
|
||||
|
||||
ok( true, "no stack overflow" );
|
||||
assert.ok( true, "no stack overflow" );
|
||||
});
|
||||
|
||||
test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function() {
|
||||
QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function( assert ) {
|
||||
|
||||
expect( 1 );
|
||||
assert.expect( 1 );
|
||||
|
||||
var cb = jQuery.Callbacks(),
|
||||
fired = false,
|
||||
@ -364,5 +364,5 @@ test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function(
|
||||
cb.empty();
|
||||
cb.add( shot );
|
||||
cb.fire();
|
||||
ok( !fired, "Disabled callback function didn't fire" );
|
||||
assert.ok( !fired, "Disabled callback function didn't fire" );
|
||||
});
|
||||
|
1060
test/unit/core.js
1060
test/unit/core.js
File diff suppressed because it is too large
Load Diff
569
test/unit/css.js
569
test/unit/css.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
module( "deferred", {
|
||||
QUnit.module( "deferred", {
|
||||
teardown: moduleTeardown
|
||||
});
|
||||
|
||||
@ -8,51 +8,51 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
return withNew ? new jQuery.Deferred( fn ) : jQuery.Deferred( fn );
|
||||
}
|
||||
|
||||
test( "jQuery.Deferred" + withNew, function() {
|
||||
QUnit.test( "jQuery.Deferred" + withNew, function( assert ) {
|
||||
|
||||
expect( 23 );
|
||||
assert.expect( 23 );
|
||||
|
||||
var defer = createDeferred();
|
||||
|
||||
ok( jQuery.isFunction( defer.pipe ), "defer.pipe is a function" );
|
||||
assert.ok( jQuery.isFunction( defer.pipe ), "defer.pipe is a function" );
|
||||
|
||||
createDeferred().resolve().done(function() {
|
||||
ok( true, "Success on resolve" );
|
||||
strictEqual( this.state(), "resolved", "Deferred is resolved (state)" );
|
||||
assert.ok( true, "Success on resolve" );
|
||||
assert.strictEqual( this.state(), "resolved", "Deferred is resolved (state)" );
|
||||
}).fail(function() {
|
||||
ok( false, "Error on resolve" );
|
||||
assert.ok( false, "Error on resolve" );
|
||||
}).always(function() {
|
||||
ok( true, "Always callback on resolve" );
|
||||
assert.ok( true, "Always callback on resolve" );
|
||||
});
|
||||
|
||||
createDeferred().reject().done(function() {
|
||||
ok( false, "Success on reject" );
|
||||
assert.ok( false, "Success on reject" );
|
||||
}).fail(function() {
|
||||
ok( true, "Error on reject" );
|
||||
strictEqual( this.state(), "rejected", "Deferred is rejected (state)" );
|
||||
assert.ok( true, "Error on reject" );
|
||||
assert.strictEqual( this.state(), "rejected", "Deferred is rejected (state)" );
|
||||
}).always(function() {
|
||||
ok( true, "Always callback on reject" );
|
||||
assert.ok( true, "Always callback on reject" );
|
||||
});
|
||||
|
||||
createDeferred(function( defer ) {
|
||||
ok( this === defer, "Defer passed as this & first argument" );
|
||||
assert.ok( this === defer, "Defer passed as this & first argument" );
|
||||
this.resolve("done");
|
||||
}).done(function( value ) {
|
||||
strictEqual( value, "done", "Passed function executed" );
|
||||
assert.strictEqual( value, "done", "Passed function executed" );
|
||||
});
|
||||
|
||||
createDeferred(function( defer ) {
|
||||
var promise = defer.promise(),
|
||||
func = function() {},
|
||||
funcPromise = defer.promise( func );
|
||||
strictEqual( defer.promise(), promise, "promise is always the same" );
|
||||
strictEqual( funcPromise, func, "non objects get extended" );
|
||||
assert.strictEqual( defer.promise(), promise, "promise is always the same" );
|
||||
assert.strictEqual( funcPromise, func, "non objects get extended" );
|
||||
jQuery.each( promise, function( key ) {
|
||||
if ( !jQuery.isFunction( promise[ key ] ) ) {
|
||||
ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" );
|
||||
assert.ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" );
|
||||
}
|
||||
if ( promise[ key ] !== func[ key ] ) {
|
||||
strictEqual( func[ key ], promise[ key ], key + " is the same" );
|
||||
assert.strictEqual( func[ key ], promise[ key ], key + " is the same" );
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -60,17 +60,17 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach( "resolve reject".split(" "), function( _, change ) {
|
||||
createDeferred(function( defer ) {
|
||||
strictEqual( defer.state(), "pending", "pending after creation" );
|
||||
assert.strictEqual( defer.state(), "pending", "pending after creation" );
|
||||
var checked = 0;
|
||||
defer.progress(function( value ) {
|
||||
strictEqual( value, checked, "Progress: right value (" + value + ") received" );
|
||||
assert.strictEqual( value, checked, "Progress: right value (" + value + ") received" );
|
||||
});
|
||||
for ( checked = 0; checked < 3; checked++ ) {
|
||||
defer.notify( checked );
|
||||
}
|
||||
strictEqual( defer.state(), "pending", "pending after notification" );
|
||||
assert.strictEqual( defer.state(), "pending", "pending after notification" );
|
||||
defer[ change ]();
|
||||
notStrictEqual( defer.state(), "pending", "not pending after " + change );
|
||||
assert.notStrictEqual( defer.state(), "pending", "not pending after " + change );
|
||||
defer.notify();
|
||||
});
|
||||
});
|
||||
@ -78,22 +78,22 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
|
||||
});
|
||||
|
||||
|
||||
test( "jQuery.Deferred - chainability", function() {
|
||||
QUnit.test( "jQuery.Deferred - chainability", function( assert ) {
|
||||
|
||||
var defer = jQuery.Deferred();
|
||||
|
||||
expect( 10 );
|
||||
assert.expect( 10 );
|
||||
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach( "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split(" "), function( _, method ) {
|
||||
var object = {
|
||||
m: defer[ method ]
|
||||
};
|
||||
strictEqual( object.m(), object, method + " is chainable" );
|
||||
assert.strictEqual( object.m(), object, method + " is chainable" );
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
|
||||
|
||||
assert.expect( 4 );
|
||||
|
||||
@ -130,7 +130,7 @@ test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
|
||||
|
||||
assert.expect( 4 );
|
||||
|
||||
@ -167,7 +167,7 @@ test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.catch", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.catch", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var value1, value2, value3,
|
||||
@ -203,7 +203,7 @@ test( "jQuery.Deferred.catch", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) {
|
||||
QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) {
|
||||
|
||||
assert.expect( 4 );
|
||||
|
||||
@ -240,7 +240,7 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert )
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
|
||||
|
||||
assert.expect( 3 );
|
||||
|
||||
@ -268,7 +268,7 @@ test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
|
||||
|
||||
assert.expect( 3 );
|
||||
|
||||
@ -300,7 +300,7 @@ test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
|
||||
|
||||
assert.expect( 3 );
|
||||
|
||||
@ -332,7 +332,7 @@ test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
|
||||
|
||||
assert.expect( 3 );
|
||||
|
||||
@ -372,7 +372,7 @@ test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert ) {
|
||||
QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert ) {
|
||||
|
||||
assert.expect( 3 );
|
||||
|
||||
@ -404,7 +404,7 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.then - context", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.then - context", function( assert ) {
|
||||
|
||||
assert.expect( 7 );
|
||||
|
||||
@ -455,7 +455,7 @@ test( "jQuery.Deferred.then - context", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
|
||||
QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
|
||||
|
||||
assert.expect( 7 );
|
||||
|
||||
@ -506,9 +506,9 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "jQuery.Deferred.then - spec compatibility", function() {
|
||||
QUnit.asyncTest( "jQuery.Deferred.then - spec compatibility", function( assert ) {
|
||||
|
||||
expect( 1 );
|
||||
assert.expect( 1 );
|
||||
|
||||
var defer = jQuery.Deferred().done(function() {
|
||||
setTimeout( start );
|
||||
@ -516,7 +516,7 @@ asyncTest( "jQuery.Deferred.then - spec compatibility", function() {
|
||||
});
|
||||
|
||||
defer.then(function() {
|
||||
ok( true, "errors in .done callbacks don't stop .then handlers" );
|
||||
assert.ok( true, "errors in .done callbacks don't stop .then handlers" );
|
||||
});
|
||||
|
||||
try {
|
||||
@ -524,9 +524,9 @@ asyncTest( "jQuery.Deferred.then - spec compatibility", function() {
|
||||
} catch ( _ ) {}
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
|
||||
|
||||
expect( 8 );
|
||||
assert.expect( 8 );
|
||||
|
||||
var context = { id: "callback context" },
|
||||
thenable = jQuery.Deferred().resolve( "thenable fulfillment" ).promise(),
|
||||
@ -575,16 +575,16 @@ test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred.then - progress and thenables", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred.then - progress and thenables", function( assert ) {
|
||||
|
||||
expect( 2 );
|
||||
assert.expect( 2 );
|
||||
|
||||
var trigger = jQuery.Deferred().notify(),
|
||||
expectedProgress = [ "baz", "baz" ],
|
||||
done = jQuery.map( new Array( 2 ), function() { return assert.async(); } ),
|
||||
failer = function( evt ) {
|
||||
return function() {
|
||||
ok( false, "no unexpected " + evt );
|
||||
assert.ok( false, "no unexpected " + evt );
|
||||
};
|
||||
};
|
||||
|
||||
@ -601,9 +601,9 @@ test( "jQuery.Deferred.then - progress and thenables", function( assert ) {
|
||||
trigger.notify();
|
||||
});
|
||||
|
||||
test( "jQuery.Deferred - notify and resolve", function( assert ) {
|
||||
QUnit.test( "jQuery.Deferred - notify and resolve", function( assert ) {
|
||||
|
||||
expect( 7 );
|
||||
assert.expect( 7 );
|
||||
|
||||
var notifiedResolved = jQuery.Deferred().notify( "foo" )/*xxx .resolve( "bar" )*/,
|
||||
done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
|
||||
@ -649,9 +649,9 @@ test( "jQuery.Deferred - notify and resolve", function( assert ) {
|
||||
} );
|
||||
});
|
||||
|
||||
test( "jQuery.when", function() {
|
||||
QUnit.test( "jQuery.when", function( assert ) {
|
||||
|
||||
expect( 37 );
|
||||
assert.expect( 37 );
|
||||
|
||||
// Some other objects
|
||||
jQuery.each({
|
||||
@ -667,22 +667,22 @@ test( "jQuery.when", function() {
|
||||
"an array": [ 1, 2, 3 ]
|
||||
|
||||
}, function( message, value ) {
|
||||
ok(
|
||||
assert.ok(
|
||||
jQuery.isFunction(
|
||||
jQuery.when( value ).done(function( resolveValue ) {
|
||||
strictEqual( this, window, "Context is the global object with " + message );
|
||||
strictEqual( resolveValue, value, "Test the promise was resolved with " + message );
|
||||
assert.strictEqual( this, window, "Context is the global object with " + message );
|
||||
assert.strictEqual( resolveValue, value, "Test the promise was resolved with " + message );
|
||||
}).promise
|
||||
),
|
||||
"Test " + message + " triggers the creation of a new Promise"
|
||||
);
|
||||
});
|
||||
|
||||
ok(
|
||||
assert.ok(
|
||||
jQuery.isFunction(
|
||||
jQuery.when().done(function( resolveValue ) {
|
||||
strictEqual( this, window, "Test the promise was resolved with window as its context" );
|
||||
strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" );
|
||||
assert.strictEqual( this, window, "Test the promise was resolved with window as its context" );
|
||||
assert.strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" );
|
||||
}).promise
|
||||
),
|
||||
"Test calling when with no parameter triggers the creation of a new Promise"
|
||||
@ -692,7 +692,7 @@ test( "jQuery.when", function() {
|
||||
context = {};
|
||||
|
||||
jQuery.when( jQuery.Deferred().resolveWith( context ) ).done(function() {
|
||||
strictEqual( this, context, "when( promise ) propagates context" );
|
||||
assert.strictEqual( this, context, "when( promise ) propagates context" );
|
||||
});
|
||||
|
||||
jQuery.each([ 1, 2, 3 ], function( k, i ) {
|
||||
@ -702,16 +702,16 @@ test( "jQuery.when", function() {
|
||||
})
|
||||
).done(function( value ) {
|
||||
|
||||
strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) );
|
||||
assert.strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) );
|
||||
cache = value;
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.when - joined", function() {
|
||||
QUnit.test( "jQuery.when - joined", function( assert ) {
|
||||
|
||||
expect( 195 );
|
||||
assert.expect( 195 );
|
||||
|
||||
var deferreds = {
|
||||
rawValue: 1,
|
||||
@ -741,11 +741,11 @@ test( "jQuery.when - joined", function() {
|
||||
},
|
||||
counter = 49;
|
||||
|
||||
stop();
|
||||
QUnit.stop();
|
||||
|
||||
function restart() {
|
||||
if ( !--counter ) {
|
||||
start();
|
||||
QUnit.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -764,22 +764,22 @@ test( "jQuery.when - joined", function() {
|
||||
|
||||
jQuery.when( defer1, defer2 ).done(function( a, b ) {
|
||||
if ( shouldResolve ) {
|
||||
deepEqual( [ a, b ], expected, code + " => resolve" );
|
||||
strictEqual( this[ 0 ], context1, code + " => first context OK" );
|
||||
strictEqual( this[ 1 ], context2, code + " => second context OK" );
|
||||
assert.deepEqual( [ a, b ], expected, code + " => resolve" );
|
||||
assert.strictEqual( this[ 0 ], context1, code + " => first context OK" );
|
||||
assert.strictEqual( this[ 1 ], context2, code + " => second context OK" );
|
||||
} else {
|
||||
ok( false, code + " => resolve" );
|
||||
assert.ok( false, code + " => resolve" );
|
||||
}
|
||||
}).fail(function( a, b ) {
|
||||
if ( shouldError ) {
|
||||
deepEqual( [ a, b ], expected, code + " => reject" );
|
||||
assert.deepEqual( [ a, b ], expected, code + " => reject" );
|
||||
} else {
|
||||
ok( false, code + " => reject" );
|
||||
assert.ok( false, code + " => reject" );
|
||||
}
|
||||
}).progress(function( a, b ) {
|
||||
deepEqual( [ a, b ], expectedNotify, code + " => progress" );
|
||||
strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" );
|
||||
strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" );
|
||||
assert.deepEqual( [ a, b ], expectedNotify, code + " => progress" );
|
||||
assert.strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" );
|
||||
assert.strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" );
|
||||
}).always( restart );
|
||||
});
|
||||
});
|
||||
@ -787,69 +787,69 @@ test( "jQuery.when - joined", function() {
|
||||
deferreds.eventuallyRejected.reject( 0 );
|
||||
});
|
||||
|
||||
test( "jQuery.when - resolved", function() {
|
||||
QUnit.test( "jQuery.when - resolved", function( assert ) {
|
||||
|
||||
expect( 6 );
|
||||
assert.expect( 6 );
|
||||
|
||||
var a = jQuery.Deferred().notify( 1 ).resolve( 4 ),
|
||||
b = jQuery.Deferred().notify( 2 ).resolve( 5 ),
|
||||
c = jQuery.Deferred().notify( 3 ).resolve( 6 );
|
||||
|
||||
jQuery.when( a, b, c ).progress(function( a, b, c ) {
|
||||
strictEqual( a, 1, "first notify value ok" );
|
||||
strictEqual( b, 2, "second notify value ok" );
|
||||
strictEqual( c, 3, "third notify value ok" );
|
||||
assert.strictEqual( a, 1, "first notify value ok" );
|
||||
assert.strictEqual( b, 2, "second notify value ok" );
|
||||
assert.strictEqual( c, 3, "third notify value ok" );
|
||||
}).done(function( a, b, c ) {
|
||||
strictEqual( a, 4, "first resolve value ok" );
|
||||
strictEqual( b, 5, "second resolve value ok" );
|
||||
strictEqual( c, 6, "third resolve value ok" );
|
||||
assert.strictEqual( a, 4, "first resolve value ok" );
|
||||
assert.strictEqual( b, 5, "second resolve value ok" );
|
||||
assert.strictEqual( c, 6, "third resolve value ok" );
|
||||
}).fail(function() {
|
||||
ok( false, "Error on resolve" );
|
||||
assert.ok( false, "Error on resolve" );
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.when - filtering", function() {
|
||||
QUnit.test( "jQuery.when - filtering", function( assert ) {
|
||||
|
||||
expect( 2 );
|
||||
assert.expect( 2 );
|
||||
|
||||
function increment( x ) {
|
||||
return x + 1;
|
||||
}
|
||||
|
||||
stop();
|
||||
QUnit.stop();
|
||||
|
||||
jQuery.when(
|
||||
jQuery.Deferred().resolve( 3 ).then( increment ),
|
||||
jQuery.Deferred().reject( 5 ).then( null, increment )
|
||||
).done(function( four, six ) {
|
||||
strictEqual( four, 4, "resolved value incremented" );
|
||||
strictEqual( six, 6, "rejected value incremented" );
|
||||
start();
|
||||
assert.strictEqual( four, 4, "resolved value incremented" );
|
||||
assert.strictEqual( six, 6, "rejected value incremented" );
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.when - exceptions", function() {
|
||||
QUnit.test( "jQuery.when - exceptions", function( assert ) {
|
||||
|
||||
expect( 2 );
|
||||
assert.expect( 2 );
|
||||
|
||||
function woops() {
|
||||
throw "exception thrown";
|
||||
}
|
||||
|
||||
stop();
|
||||
QUnit.stop();
|
||||
|
||||
jQuery.Deferred().resolve().then( woops ).fail(function( doneException ) {
|
||||
strictEqual( doneException, "exception thrown", "throwing in done handler" );
|
||||
assert.strictEqual( doneException, "exception thrown", "throwing in done handler" );
|
||||
jQuery.Deferred().reject().then( null, woops ).fail(function( failException ) {
|
||||
strictEqual( failException, "exception thrown", "throwing in fail handler" );
|
||||
start();
|
||||
assert.strictEqual( failException, "exception thrown", "throwing in fail handler" );
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.when - chaining", function() {
|
||||
QUnit.test( "jQuery.when - chaining", function( assert ) {
|
||||
|
||||
expect( 4 );
|
||||
assert.expect( 4 );
|
||||
|
||||
var defer = jQuery.Deferred();
|
||||
|
||||
@ -861,7 +861,7 @@ test( "jQuery.when - chaining", function() {
|
||||
return Promise.resolve( "std deferred" );
|
||||
}
|
||||
|
||||
stop();
|
||||
QUnit.stop();
|
||||
|
||||
jQuery.when(
|
||||
jQuery.Deferred().resolve( 3 ).then( chain ),
|
||||
@ -869,11 +869,11 @@ test( "jQuery.when - chaining", function() {
|
||||
jQuery.Deferred().resolve( 3 ).then( chainStandard ),
|
||||
jQuery.Deferred().reject( 5 ).then( null, chainStandard )
|
||||
).done(function( v1, v2, s1, s2 ) {
|
||||
strictEqual( v1, "other deferred", "chaining in done handler" );
|
||||
strictEqual( v2, "other deferred", "chaining in fail handler" );
|
||||
strictEqual( s1, "std deferred", "chaining thenable in done handler" );
|
||||
strictEqual( s2, "std deferred", "chaining thenable in fail handler" );
|
||||
start();
|
||||
assert.strictEqual( v1, "other deferred", "chaining in done handler" );
|
||||
assert.strictEqual( v2, "other deferred", "chaining in fail handler" );
|
||||
assert.strictEqual( s1, "std deferred", "chaining thenable in done handler" );
|
||||
assert.strictEqual( s2, "std deferred", "chaining thenable in fail handler" );
|
||||
QUnit.start();
|
||||
});
|
||||
|
||||
defer.resolve( "other deferred" );
|
||||
|
@ -1,2 +1,2 @@
|
||||
module("deprecated", { teardown: moduleTeardown });
|
||||
QUnit.module("deprecated", { teardown: moduleTeardown });
|
||||
|
||||
|
@ -4,7 +4,7 @@ if ( !jQuery.fn.width ) {
|
||||
return;
|
||||
}
|
||||
|
||||
module("dimensions", { teardown: moduleTeardown });
|
||||
QUnit.module("dimensions", { teardown: moduleTeardown });
|
||||
|
||||
function pass( val ) {
|
||||
return val;
|
||||
@ -21,127 +21,127 @@ function fn( val ) {
|
||||
pass and fn can be used to test passing functions to setters
|
||||
See testWidth below for an example
|
||||
|
||||
pass( value );
|
||||
pass( value, assert );
|
||||
This function returns whatever value is passed in
|
||||
|
||||
fn( value );
|
||||
fn( value, assert );
|
||||
Returns a function that returns the value
|
||||
*/
|
||||
|
||||
function testWidth( val ) {
|
||||
expect(9);
|
||||
function testWidth( val, assert ) {
|
||||
assert.expect(9);
|
||||
var $div, blah;
|
||||
|
||||
$div = jQuery("#nothiddendiv");
|
||||
$div.width( val(30) );
|
||||
equal($div.width(), 30, "Test set to 30 correctly");
|
||||
assert.equal($div.width(), 30, "Test set to 30 correctly");
|
||||
$div.hide();
|
||||
equal($div.width(), 30, "Test hidden div");
|
||||
assert.equal($div.width(), 30, "Test hidden div");
|
||||
$div.show();
|
||||
$div.width( val(-1) ); // handle negative numbers by setting to 0 #11604
|
||||
equal($div.width(), 0, "Test negative width normalized to 0");
|
||||
assert.equal($div.width(), 0, "Test negative width normalized to 0");
|
||||
$div.css("padding", "20px");
|
||||
equal($div.width(), 0, "Test padding specified with pixels");
|
||||
assert.equal($div.width(), 0, "Test padding specified with pixels");
|
||||
$div.css("border", "2px solid #fff");
|
||||
equal($div.width(), 0, "Test border specified with pixels");
|
||||
assert.equal($div.width(), 0, "Test border specified with pixels");
|
||||
|
||||
$div.css({ "display": "", "border": "", "padding": "" });
|
||||
|
||||
jQuery("#nothiddendivchild").css({ "width": 20, "padding": "3px", "border": "2px solid #fff" });
|
||||
equal(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
|
||||
assert.equal(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
|
||||
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "width": "" });
|
||||
|
||||
blah = jQuery("blah");
|
||||
equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
|
||||
equal( blah.width(), null, "Make sure 'null' is returned on an empty set");
|
||||
assert.equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
|
||||
assert.equal( blah.width(), null, "Make sure 'null' is returned on an empty set");
|
||||
|
||||
equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
|
||||
assert.equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
|
||||
|
||||
QUnit.expectJqData( this, $div[0], "olddisplay" );
|
||||
}
|
||||
|
||||
test("width()", function() {
|
||||
testWidth( pass );
|
||||
QUnit.test("width()", function( assert ) {
|
||||
testWidth( pass, assert );
|
||||
});
|
||||
|
||||
test("width(Function)", function() {
|
||||
testWidth( fn );
|
||||
QUnit.test("width(Function)", function( assert ) {
|
||||
testWidth( fn, assert );
|
||||
});
|
||||
|
||||
test("width(Function(args))", function() {
|
||||
expect( 2 );
|
||||
QUnit.test("width(Function(args))", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
$div.width( 30 ).width(function(i, width) {
|
||||
equal( width, 30, "Make sure previous value is correct." );
|
||||
assert.equal( width, 30, "Make sure previous value is correct." );
|
||||
return width + 1;
|
||||
});
|
||||
|
||||
equal( $div.width(), 31, "Make sure value was modified correctly." );
|
||||
assert.equal( $div.width(), 31, "Make sure value was modified correctly." );
|
||||
});
|
||||
|
||||
function testHeight( val ) {
|
||||
expect(9);
|
||||
function testHeight( val, assert ) {
|
||||
assert.expect(9);
|
||||
|
||||
var $div, blah;
|
||||
|
||||
$div = jQuery("#nothiddendiv");
|
||||
$div.height( val(30) );
|
||||
equal($div.height(), 30, "Test set to 30 correctly");
|
||||
assert.equal($div.height(), 30, "Test set to 30 correctly");
|
||||
$div.hide();
|
||||
equal($div.height(), 30, "Test hidden div");
|
||||
assert.equal($div.height(), 30, "Test hidden div");
|
||||
$div.show();
|
||||
$div.height( val(-1) ); // handle negative numbers by setting to 0 #11604
|
||||
equal($div.height(), 0, "Test negative height normalized to 0");
|
||||
assert.equal($div.height(), 0, "Test negative height normalized to 0");
|
||||
$div.css("padding", "20px");
|
||||
equal($div.height(), 0, "Test padding specified with pixels");
|
||||
assert.equal($div.height(), 0, "Test padding specified with pixels");
|
||||
$div.css("border", "2px solid #fff");
|
||||
equal($div.height(), 0, "Test border specified with pixels");
|
||||
assert.equal($div.height(), 0, "Test border specified with pixels");
|
||||
|
||||
$div.css({ "display": "", "border": "", "padding": "", "height": "1px" });
|
||||
|
||||
jQuery("#nothiddendivchild").css({ "height": 20, "padding": "3px", "border": "2px solid #fff" });
|
||||
equal(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
|
||||
assert.equal(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
|
||||
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "height": "" });
|
||||
|
||||
blah = jQuery("blah");
|
||||
equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
|
||||
equal( blah.height(), null, "Make sure 'null' is returned on an empty set");
|
||||
assert.equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
|
||||
assert.equal( blah.height(), null, "Make sure 'null' is returned on an empty set");
|
||||
|
||||
equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
|
||||
assert.equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
|
||||
|
||||
QUnit.expectJqData( this, $div[0], "olddisplay" );
|
||||
}
|
||||
|
||||
test("height()", function() {
|
||||
testHeight( pass );
|
||||
QUnit.test("height()", function( assert ) {
|
||||
testHeight( pass, assert );
|
||||
});
|
||||
|
||||
test("height(Function)", function() {
|
||||
testHeight( fn );
|
||||
QUnit.test("height(Function)", function( assert ) {
|
||||
testHeight( fn, assert );
|
||||
});
|
||||
|
||||
test("height(Function(args))", function() {
|
||||
expect( 2 );
|
||||
QUnit.test("height(Function(args))", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var $div = jQuery("#nothiddendiv");
|
||||
$div.height( 30 ).height(function(i, height) {
|
||||
equal( height, 30, "Make sure previous value is correct." );
|
||||
assert.equal( height, 30, "Make sure previous value is correct." );
|
||||
return height + 1;
|
||||
});
|
||||
|
||||
equal( $div.height(), 31, "Make sure value was modified correctly." );
|
||||
assert.equal( $div.height(), 31, "Make sure value was modified correctly." );
|
||||
});
|
||||
|
||||
test("innerWidth()", function() {
|
||||
expect( 6 );
|
||||
QUnit.test("innerWidth()", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var $div, div,
|
||||
$win = jQuery( window ),
|
||||
$doc = jQuery( document );
|
||||
|
||||
equal( jQuery( window ).innerWidth(), $win.width(), "Test on window" );
|
||||
equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" );
|
||||
assert.equal( jQuery( window ).innerWidth(), $win.width(), "Test on window" );
|
||||
assert.equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css({
|
||||
@ -150,11 +150,11 @@ test("innerWidth()", function() {
|
||||
"width": 30
|
||||
});
|
||||
|
||||
equal( $div.innerWidth(), 30, "Test with margin and border" );
|
||||
assert.equal( $div.innerWidth(), 30, "Test with margin and border" );
|
||||
$div.css( "padding", "20px" );
|
||||
equal( $div.innerWidth(), 70, "Test with margin, border and padding" );
|
||||
assert.equal( $div.innerWidth(), 70, "Test with margin, border and padding" );
|
||||
$div.hide();
|
||||
equal( $div.innerWidth(), 70, "Test hidden div" );
|
||||
assert.equal( $div.innerWidth(), 70, "Test hidden div" );
|
||||
|
||||
// reset styles
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
@ -162,21 +162,21 @@ test("innerWidth()", function() {
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
// Temporarily require 0 for backwards compat - should be auto
|
||||
equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
||||
assert.equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
});
|
||||
|
||||
test("innerHeight()", function() {
|
||||
expect( 6 );
|
||||
QUnit.test("innerHeight()", function( assert ) {
|
||||
assert.expect( 6 );
|
||||
|
||||
var $div, div,
|
||||
$win = jQuery( window ),
|
||||
$doc = jQuery( document );
|
||||
|
||||
equal( jQuery( window ).innerHeight(), $win.height(), "Test on window" );
|
||||
equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" );
|
||||
assert.equal( jQuery( window ).innerHeight(), $win.height(), "Test on window" );
|
||||
assert.equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css({
|
||||
@ -185,11 +185,11 @@ test("innerHeight()", function() {
|
||||
"height": 30
|
||||
});
|
||||
|
||||
equal( $div.innerHeight(), 30, "Test with margin and border" );
|
||||
assert.equal( $div.innerHeight(), 30, "Test with margin and border" );
|
||||
$div.css( "padding", "20px" );
|
||||
equal( $div.innerHeight(), 70, "Test with margin, border and padding" );
|
||||
assert.equal( $div.innerHeight(), 70, "Test with margin, border and padding" );
|
||||
$div.hide();
|
||||
equal( $div.innerHeight(), 70, "Test hidden div" );
|
||||
assert.equal( $div.innerHeight(), 70, "Test hidden div" );
|
||||
|
||||
// reset styles
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
@ -197,38 +197,38 @@ test("innerHeight()", function() {
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
// Temporarily require 0 for backwards compat - should be auto
|
||||
equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
||||
assert.equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
});
|
||||
|
||||
test("outerWidth()", function() {
|
||||
expect( 11 );
|
||||
QUnit.test("outerWidth()", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
var $div, div,
|
||||
$win = jQuery( window ),
|
||||
$doc = jQuery( document );
|
||||
|
||||
equal( jQuery( window ).outerWidth(), $win.width(), "Test on window without margin option" );
|
||||
equal( jQuery( window ).outerWidth( true ), $win.width(), "Test on window with margin option" );
|
||||
equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" );
|
||||
equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" );
|
||||
assert.equal( jQuery( window ).outerWidth(), $win.width(), "Test on window without margin option" );
|
||||
assert.equal( jQuery( window ).outerWidth( true ), $win.width(), "Test on window with margin option" );
|
||||
assert.equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" );
|
||||
assert.equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css( "width", 30 );
|
||||
|
||||
equal( $div.outerWidth(), 30, "Test with only width set" );
|
||||
assert.equal( $div.outerWidth(), 30, "Test with only width set" );
|
||||
$div.css( "padding", "20px" );
|
||||
equal( $div.outerWidth(), 70, "Test with padding" );
|
||||
assert.equal( $div.outerWidth(), 70, "Test with padding" );
|
||||
$div.css( "border", "2px solid #fff" );
|
||||
equal( $div.outerWidth(), 74, "Test with padding and border" );
|
||||
assert.equal( $div.outerWidth(), 74, "Test with padding and border" );
|
||||
$div.css( "margin", "10px" );
|
||||
equal( $div.outerWidth(), 74, "Test with padding, border and margin without margin option" );
|
||||
assert.equal( $div.outerWidth(), 74, "Test with padding, border and margin without margin option" );
|
||||
$div.css( "position", "absolute" );
|
||||
equal( $div.outerWidth( true ), 94, "Test with padding, border and margin with margin option" );
|
||||
assert.equal( $div.outerWidth( true ), 94, "Test with padding, border and margin with margin option" );
|
||||
$div.hide();
|
||||
equal( $div.outerWidth( true ), 94, "Test hidden div with padding, border and margin with margin option" );
|
||||
assert.equal( $div.outerWidth( true ), 94, "Test hidden div with padding, border and margin with margin option" );
|
||||
|
||||
// reset styles
|
||||
$div.css({ "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
@ -236,14 +236,14 @@ test("outerWidth()", function() {
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
// Temporarily require 0 for backwards compat - should be auto
|
||||
equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
||||
assert.equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
});
|
||||
|
||||
test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
|
||||
expect(16);
|
||||
QUnit.test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function( assert ) {
|
||||
assert.expect(16);
|
||||
|
||||
// setup html
|
||||
var $divNormal = jQuery("<div>").css({ "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
|
||||
@ -253,38 +253,38 @@ test("child of a hidden elem (or unconnected node) has accurate inner/outer/Widt
|
||||
$divNormal.appendTo("body");
|
||||
|
||||
// tests that child div of a hidden div works the same as a normal div
|
||||
equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
|
||||
equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
|
||||
equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
|
||||
equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
|
||||
assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
|
||||
assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
|
||||
assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
|
||||
assert.equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
|
||||
|
||||
// Support: IE 10-11, Edge
|
||||
// Child height is not always decimal
|
||||
equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #9441" );
|
||||
equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #9441" );
|
||||
equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #9441" );
|
||||
equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
|
||||
assert.equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #9441" );
|
||||
assert.equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #9441" );
|
||||
assert.equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #9441" );
|
||||
assert.equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
|
||||
|
||||
// tests that child div of an unconnected div works the same as a normal div
|
||||
equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" );
|
||||
equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" );
|
||||
equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" );
|
||||
equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
|
||||
assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
|
||||
|
||||
// Support: IE 10-11, Edge
|
||||
// Child height is not always decimal
|
||||
equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #9441" );
|
||||
equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #9441" );
|
||||
equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #9441" );
|
||||
equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #9300" );
|
||||
assert.equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #9441" );
|
||||
assert.equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #9300" );
|
||||
|
||||
// teardown html
|
||||
$divHiddenParent.remove();
|
||||
$divNormal.remove();
|
||||
});
|
||||
|
||||
test("getting dimensions shouldn't modify runtimeStyle see #9233", function() {
|
||||
expect( 1 );
|
||||
QUnit.test("getting dimensions shouldn't modify runtimeStyle see #9233", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
|
||||
div = $div.get( 0 ),
|
||||
@ -298,16 +298,16 @@ test("getting dimensions shouldn't modify runtimeStyle see #9233", function() {
|
||||
$div.outerWidth( true );
|
||||
|
||||
if ( runtimeStyle ) {
|
||||
equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" );
|
||||
assert.equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" );
|
||||
} else {
|
||||
ok( true, "this browser doesn't support runtimeStyle, see #9233" );
|
||||
assert.ok( true, "this browser doesn't support runtimeStyle, see #9233" );
|
||||
}
|
||||
|
||||
$div.remove();
|
||||
});
|
||||
|
||||
test( "table dimensions", function() {
|
||||
expect( 2 );
|
||||
QUnit.test( "table dimensions", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var table = jQuery("<table><colgroup><col/><col/></colgroup><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>").appendTo("#qunit-fixture"),
|
||||
tdElem = table.find("td").first(),
|
||||
@ -315,12 +315,12 @@ test( "table dimensions", function() {
|
||||
|
||||
table.find("td").css({ "margin": 0, "padding": 0 });
|
||||
|
||||
equal( tdElem.width(), tdElem.width(), "width() doesn't alter dimension values of empty cells, see #11293" );
|
||||
equal( colElem.width(), 300, "col elements have width(), see #12243" );
|
||||
assert.equal( tdElem.width(), tdElem.width(), "width() doesn't alter dimension values of empty cells, see #11293" );
|
||||
assert.equal( colElem.width(), 300, "col elements have width(), see #12243" );
|
||||
});
|
||||
|
||||
test("box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function() {
|
||||
expect(16);
|
||||
QUnit.test("box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function( assert ) {
|
||||
assert.expect(16);
|
||||
|
||||
// setup html
|
||||
var $divNormal = jQuery("<div>").css({ "boxSizing": "border-box", "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
|
||||
@ -330,61 +330,61 @@ test("box-sizing:border-box child of a hidden elem (or unconnected node) has acc
|
||||
$divNormal.appendTo("body");
|
||||
|
||||
// tests that child div of a hidden div works the same as a normal div
|
||||
equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" );
|
||||
equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" );
|
||||
equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" );
|
||||
equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
|
||||
assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" );
|
||||
assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" );
|
||||
assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" );
|
||||
assert.equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
|
||||
|
||||
// Support: IE 10-11, Edge
|
||||
// Child height is not always decimal
|
||||
equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #10413" );
|
||||
equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #10413" );
|
||||
equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #10413" );
|
||||
equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #10413" );
|
||||
assert.equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #10413" );
|
||||
assert.equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #10413" );
|
||||
assert.equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #10413" );
|
||||
assert.equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #10413" );
|
||||
|
||||
// tests that child div of an unconnected div works the same as a normal div
|
||||
equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" );
|
||||
equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" );
|
||||
equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" );
|
||||
equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
|
||||
|
||||
// Support: IE 10-11, Edge
|
||||
// Child height is not always decimal
|
||||
equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #10413" );
|
||||
equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #10413" );
|
||||
equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #10413" );
|
||||
equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #10413" );
|
||||
assert.equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #10413" );
|
||||
|
||||
// teardown html
|
||||
$divHiddenParent.remove();
|
||||
$divNormal.remove();
|
||||
});
|
||||
|
||||
test("outerHeight()", function() {
|
||||
expect( 11 );
|
||||
QUnit.test("outerHeight()", function( assert ) {
|
||||
assert.expect( 11 );
|
||||
|
||||
var $div, div,
|
||||
$win = jQuery( window ),
|
||||
$doc = jQuery( document );
|
||||
|
||||
equal( jQuery( window ).outerHeight(), $win.height(), "Test on window without margin option" );
|
||||
equal( jQuery( window ).outerHeight( true ), $win.height(), "Test on window with margin option" );
|
||||
equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" );
|
||||
equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" );
|
||||
assert.equal( jQuery( window ).outerHeight(), $win.height(), "Test on window without margin option" );
|
||||
assert.equal( jQuery( window ).outerHeight( true ), $win.height(), "Test on window with margin option" );
|
||||
assert.equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" );
|
||||
assert.equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" );
|
||||
|
||||
$div = jQuery( "#nothiddendiv" );
|
||||
$div.css( "height", 30 );
|
||||
|
||||
equal( $div.outerHeight(), 30, "Test with only width set" );
|
||||
assert.equal( $div.outerHeight(), 30, "Test with only width set" );
|
||||
$div.css( "padding", "20px" );
|
||||
equal( $div.outerHeight(), 70, "Test with padding" );
|
||||
assert.equal( $div.outerHeight(), 70, "Test with padding" );
|
||||
$div.css( "border", "2px solid #fff" );
|
||||
equal( $div.outerHeight(), 74, "Test with padding and border" );
|
||||
assert.equal( $div.outerHeight(), 74, "Test with padding and border" );
|
||||
$div.css( "margin", "10px" );
|
||||
equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" );
|
||||
equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" );
|
||||
assert.equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" );
|
||||
assert.equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" );
|
||||
$div.hide();
|
||||
equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" );
|
||||
assert.equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" );
|
||||
|
||||
// reset styles
|
||||
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
|
||||
@ -392,78 +392,82 @@ test("outerHeight()", function() {
|
||||
div = jQuery( "<div>" );
|
||||
|
||||
// Temporarily require 0 for backwards compat - should be auto
|
||||
equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
||||
assert.equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
|
||||
|
||||
div.remove();
|
||||
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
|
||||
});
|
||||
|
||||
test("passing undefined is a setter #5571", function() {
|
||||
expect(4);
|
||||
equal(jQuery("#nothiddendiv").height(30).height(undefined).height(), 30, ".height(undefined) is chainable (#5571)");
|
||||
equal(jQuery("#nothiddendiv").height(30).innerHeight(undefined).height(), 30, ".innerHeight(undefined) is chainable (#5571)");
|
||||
equal(jQuery("#nothiddendiv").height(30).outerHeight(undefined).height(), 30, ".outerHeight(undefined) is chainable (#5571)");
|
||||
equal(jQuery("#nothiddendiv").width(30).width(undefined).width(), 30, ".width(undefined) is chainable (#5571)");
|
||||
QUnit.test("passing undefined is a setter #5571", function( assert ) {
|
||||
assert.expect(4);
|
||||
assert.equal(jQuery("#nothiddendiv").height(30).height(undefined).height(), 30, ".height(undefined) is chainable (#5571)");
|
||||
assert.equal(jQuery("#nothiddendiv").height(30).innerHeight(undefined).height(), 30, ".innerHeight(undefined) is chainable (#5571)");
|
||||
assert.equal(jQuery("#nothiddendiv").height(30).outerHeight(undefined).height(), 30, ".outerHeight(undefined) is chainable (#5571)");
|
||||
assert.equal(jQuery("#nothiddendiv").width(30).width(undefined).width(), 30, ".width(undefined) is chainable (#5571)");
|
||||
});
|
||||
|
||||
test( "getters on non elements should return null", function() {
|
||||
expect( 8 );
|
||||
QUnit.test( "getters on non elements should return null", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
|
||||
var nonElem = jQuery("notAnElement");
|
||||
|
||||
strictEqual( nonElem.width(), null, ".width() is not null (#12283)" );
|
||||
strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" );
|
||||
strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" );
|
||||
strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.width(), null, ".width() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" );
|
||||
|
||||
strictEqual( nonElem.height(), null, ".height() is not null (#12283)" );
|
||||
strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" );
|
||||
strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" );
|
||||
strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.height(), null, ".height() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" );
|
||||
assert.strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" );
|
||||
});
|
||||
|
||||
test("setters with and without box-sizing:border-box", function(){
|
||||
expect(20);
|
||||
QUnit.test("setters with and without box-sizing:border-box", function( assert ){
|
||||
assert.expect(20);
|
||||
|
||||
// Support: Android 2.3 (-webkit-box-sizing).
|
||||
var el_bb = jQuery("<div style='width:114px;height:114px;margin:5px;padding:3px;border:4px solid white;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>").appendTo("#qunit-fixture"),
|
||||
el = jQuery("<div style='width:100px;height:100px;margin:5px;padding:3px;border:4px solid white;'>test</div>").appendTo("#qunit-fixture"),
|
||||
expected = 100;
|
||||
|
||||
equal( el_bb.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" );
|
||||
equal( el_bb.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" );
|
||||
equal( el_bb.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" );
|
||||
equal( el_bb.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" );
|
||||
equal( el_bb.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" );
|
||||
assert.equal( el_bb.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" );
|
||||
assert.equal( el_bb.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" );
|
||||
assert.equal( el_bb.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" );
|
||||
assert.equal( el_bb.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" );
|
||||
assert.equal( el_bb.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" );
|
||||
|
||||
equal( el_bb.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" );
|
||||
equal( el_bb.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" );
|
||||
equal( el_bb.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" );
|
||||
equal( el_bb.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" );
|
||||
equal( el_bb.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
|
||||
assert.equal( el_bb.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" );
|
||||
assert.equal( el_bb.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" );
|
||||
assert.equal( el_bb.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" );
|
||||
assert.equal( el_bb.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" );
|
||||
assert.equal( el_bb.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
|
||||
|
||||
equal( el.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" );
|
||||
equal( el.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" );
|
||||
equal( el.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" );
|
||||
equal( el.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" );
|
||||
equal( el.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" );
|
||||
assert.equal( el.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" );
|
||||
assert.equal( el.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" );
|
||||
assert.equal( el.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" );
|
||||
assert.equal( el.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" );
|
||||
assert.equal( el.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" );
|
||||
|
||||
equal( el.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" );
|
||||
equal( el.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" );
|
||||
equal( el.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" );
|
||||
equal( el.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" );
|
||||
equal( el.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
|
||||
assert.equal( el.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" );
|
||||
assert.equal( el.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" );
|
||||
assert.equal( el.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" );
|
||||
assert.equal( el.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" );
|
||||
assert.equal( el.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
|
||||
});
|
||||
|
||||
testIframe( "dimensions/documentLarge", "window vs. large document", function( jQuery, window, document ) {
|
||||
expect(2);
|
||||
testIframe(
|
||||
"dimensions/documentLarge",
|
||||
"window vs. large document",
|
||||
function( jQuery, window, document, assert ) {
|
||||
assert.expect(2);
|
||||
|
||||
ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" );
|
||||
ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" );
|
||||
});
|
||||
assert.ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" );
|
||||
assert.ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" );
|
||||
}
|
||||
);
|
||||
|
||||
test( "allow modification of coordinates argument (gh-1848)", function() {
|
||||
expect( 1 );
|
||||
QUnit.test( "allow modification of coordinates argument (gh-1848)", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var offsetTop,
|
||||
element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
@ -475,7 +479,7 @@ test( "allow modification of coordinates argument (gh-1848)", function() {
|
||||
});
|
||||
|
||||
offsetTop = element.offset().top;
|
||||
ok( Math.abs(offsetTop - 100) < 0.02,
|
||||
assert.ok( Math.abs(offsetTop - 100) < 0.02,
|
||||
"coordinates are modified (got offset.top: " + offsetTop + ")");
|
||||
});
|
||||
|
||||
|
903
test/unit/effects.js
vendored
903
test/unit/effects.js
vendored
File diff suppressed because it is too large
Load Diff
1150
test/unit/event.js
1150
test/unit/event.js
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
module("exports", { teardown: moduleTeardown });
|
||||
QUnit.module("exports", { teardown: moduleTeardown });
|
||||
|
||||
test("amdModule", function() {
|
||||
expect(1);
|
||||
QUnit.test("amdModule", function( assert ) {
|
||||
assert.expect(1);
|
||||
|
||||
equal( jQuery, amdDefined, "Make sure defined module matches jQuery" );
|
||||
assert.equal( jQuery, amdDefined, "Make sure defined module matches jQuery" );
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@ var supportsScroll, supportsFixedPosition,
|
||||
checkFixed.remove();
|
||||
};
|
||||
|
||||
module("offset", { setup: function(){
|
||||
QUnit.module("offset", { setup: function(){
|
||||
if ( typeof checkSupport === "function" ) {
|
||||
checkSupport();
|
||||
}
|
||||
@ -41,26 +41,26 @@ module("offset", { setup: function(){
|
||||
the iframe window and the "jQuery" symbol is used to access any static methods.
|
||||
*/
|
||||
|
||||
test("empty set", function() {
|
||||
expect( 2 );
|
||||
strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" );
|
||||
strictEqual( jQuery().position(), undefined, "position() returns undefined for empty set (#11962)" );
|
||||
QUnit.test("empty set", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
assert.strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" );
|
||||
assert.strictEqual( jQuery().position(), undefined, "position() returns undefined for empty set (#11962)" );
|
||||
});
|
||||
|
||||
test("disconnected element", function() {
|
||||
expect( 2 );
|
||||
QUnit.test("disconnected element", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var result = jQuery( document.createElement( "div" ) ).offset();
|
||||
|
||||
// These tests are solely for master/compat consistency
|
||||
// Retrieving offset on disconnected/hidden elements is not officially
|
||||
// valid input, but will return zeros for back-compat
|
||||
equal( result.top, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
|
||||
equal( result.left, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
|
||||
assert.equal( result.top, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
|
||||
assert.equal( result.left, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
|
||||
});
|
||||
|
||||
test("hidden (display: none) element", function() {
|
||||
expect( 2 );
|
||||
QUnit.test("hidden (display: none) element", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var node = jQuery("<div style='display: none' />").appendTo("#qunit-fixture"),
|
||||
result = node.offset();
|
||||
@ -70,12 +70,12 @@ test("hidden (display: none) element", function() {
|
||||
// These tests are solely for master/compat consistency
|
||||
// Retrieving offset on disconnected/hidden elements is not officially
|
||||
// valid input, but will return zeros for back-compat
|
||||
equal( result.top, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" );
|
||||
equal( result.left, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" );
|
||||
assert.equal( result.top, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" );
|
||||
assert.equal( result.left, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" );
|
||||
});
|
||||
|
||||
testIframe("offset/absolute", "absolute", function($, iframe) {
|
||||
expect(4);
|
||||
testIframe("offset/absolute", "absolute", function( $, iframe, document, assert ) {
|
||||
assert.expect(4);
|
||||
|
||||
var doc = iframe.document,
|
||||
tests;
|
||||
@ -85,8 +85,8 @@ testIframe("offset/absolute", "absolute", function($, iframe) {
|
||||
{ "id": "#absolute-1", "top": 1, "left": 1 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this["id"], doc ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( jQuery( this["id"], doc ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
assert.equal( jQuery( this["id"], doc ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( jQuery( this["id"], doc ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
|
||||
@ -95,13 +95,13 @@ testIframe("offset/absolute", "absolute", function($, iframe) {
|
||||
{ "id": "#absolute-1", "top": 0, "left": 0 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( jQuery( this["id"], doc ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
equal( jQuery( this["id"], doc ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
assert.equal( jQuery( this["id"], doc ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
assert.equal( jQuery( this["id"], doc ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
});
|
||||
|
||||
testIframe("offset/absolute", "absolute", function( $ ) {
|
||||
expect(178);
|
||||
testIframe("offset/absolute", "absolute", function( $, window, document, assert ) {
|
||||
assert.expect(178);
|
||||
|
||||
var tests, offset;
|
||||
|
||||
@ -113,8 +113,8 @@ testIframe("offset/absolute", "absolute", function( $ ) {
|
||||
{ "id": "#absolute-2", "top": 20, "left": 20 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
|
||||
@ -126,14 +126,14 @@ testIframe("offset/absolute", "absolute", function( $ ) {
|
||||
{ "id": "#absolute-2", "top": 19, "left": 19 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
assert.equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
assert.equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
|
||||
// test #5781
|
||||
offset = $( "#positionTest" ).offset({ "top": 10, "left": 10 }).offset();
|
||||
equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||
equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||
assert.equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||
assert.equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
|
||||
|
||||
|
||||
// set offset
|
||||
@ -157,24 +157,24 @@ testIframe("offset/absolute", "absolute", function( $ ) {
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
|
||||
var top = this["top"], left = this["left"];
|
||||
|
||||
$( this["id"] ).offset(function(i, val){
|
||||
equal( val.top, top, "Verify incoming top position." );
|
||||
equal( val.left, left, "Verify incoming top position." );
|
||||
assert.equal( val.top, top, "Verify incoming top position." );
|
||||
assert.equal( val.left, left, "Verify incoming top position." );
|
||||
return { "top": top + 1, "left": left + 1 };
|
||||
});
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + " })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + " })" );
|
||||
|
||||
$( this["id"] )
|
||||
.offset({ "left": this["left"] + 2 })
|
||||
.offset({ "top": this["top"] + 2 });
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 2, "Setting one property at a time." );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 2, "Setting one property at a time." );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 2, "Setting one property at a time." );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 2, "Setting one property at a time." );
|
||||
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
@ -182,13 +182,13 @@ testIframe("offset/absolute", "absolute", function( $ ) {
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
|
||||
testIframe("offset/relative", "relative", function( $ ) {
|
||||
expect(60);
|
||||
testIframe("offset/relative", "relative", function( $, window, document, assert ) {
|
||||
assert.expect(60);
|
||||
|
||||
// get offset
|
||||
var tests = [
|
||||
@ -197,8 +197,8 @@ testIframe("offset/relative", "relative", function( $ ) {
|
||||
{ "id": "#relative-2", "top": 142, "left": 27 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
|
||||
@ -209,8 +209,8 @@ testIframe("offset/relative", "relative", function( $ ) {
|
||||
{ "id": "#relative-2", "top": 141, "left": 26 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
assert.equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
||||
assert.equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
||||
});
|
||||
|
||||
|
||||
@ -231,8 +231,8 @@ testIframe("offset/relative", "relative", function( $ ) {
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
@ -240,13 +240,13 @@ testIframe("offset/relative", "relative", function( $ ) {
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
|
||||
testIframe("offset/static", "static", function( $ ) {
|
||||
expect( 80 );
|
||||
testIframe("offset/static", "static", function( $, window, document, assert ) {
|
||||
assert.expect( 80 );
|
||||
|
||||
// get offset
|
||||
var tests = [
|
||||
@ -256,8 +256,8 @@ testIframe("offset/static", "static", function( $ ) {
|
||||
{ "id": "#static-2", "top": 122, left: 7 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
});
|
||||
|
||||
|
||||
@ -269,8 +269,8 @@ testIframe("offset/static", "static", function( $ ) {
|
||||
{ "id": "#static-2", "top": 121, "left": 6 }
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["top"] + "').position().top" );
|
||||
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["left"] +"').position().left" );
|
||||
assert.equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["top"] + "').position().top" );
|
||||
assert.equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["left"] +"').position().left" );
|
||||
});
|
||||
|
||||
|
||||
@ -295,8 +295,8 @@ testIframe("offset/static", "static", function( $ ) {
|
||||
];
|
||||
jQuery.each( tests, function() {
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
@ -304,13 +304,13 @@ testIframe("offset/static", "static", function( $ ) {
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
});
|
||||
});
|
||||
|
||||
testIframe("offset/fixed", "fixed", function( $ ) {
|
||||
expect(34);
|
||||
testIframe("offset/fixed", "fixed", function( $, window, document, assert ) {
|
||||
assert.expect(34);
|
||||
|
||||
var tests, $noTopLeft;
|
||||
|
||||
@ -333,22 +333,22 @@ testIframe("offset/fixed", "fixed", function( $ ) {
|
||||
|
||||
jQuery.each( tests, function() {
|
||||
if ( !window.supportsScroll ) {
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
|
||||
} else if ( window.supportsFixedPosition ) {
|
||||
equal( $( this["id"] ).offset().top, this["offsetTop"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
equal( $( this["id"] ).position().top, this["positionTop"], "jQuery('" + this["id"] + "').position().top" );
|
||||
equal( $( this["id"] ).offset().left, this["offsetLeft"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
equal( $( this["id"] ).position().left, this["positionLeft"], "jQuery('" + this["id"] + "').position().left" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["offsetTop"], "jQuery('" + this["id"] + "').offset().top" );
|
||||
assert.equal( $( this["id"] ).position().top, this["positionTop"], "jQuery('" + this["id"] + "').position().top" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["offsetLeft"], "jQuery('" + this["id"] + "').offset().left" );
|
||||
assert.equal( $( this["id"] ).position().left, this["positionLeft"], "jQuery('" + this["id"] + "').position().left" );
|
||||
} else {
|
||||
// need to have same number of assertions
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
|
||||
@ -364,8 +364,8 @@ testIframe("offset/fixed", "fixed", function( $ ) {
|
||||
jQuery.each( tests, function() {
|
||||
if ( window.supportsFixedPosition ) {
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
||||
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
||||
|
||||
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
||||
$( this ).css({
|
||||
@ -373,165 +373,165 @@ testIframe("offset/fixed", "fixed", function( $ ) {
|
||||
"left": props.left + 1
|
||||
});
|
||||
}});
|
||||
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
||||
assert.equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
||||
} else {
|
||||
// need to have same number of assertions
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
|
||||
// Bug 8316
|
||||
$noTopLeft = $("#fixed-no-top-left");
|
||||
if ( window.supportsFixedPosition ) {
|
||||
equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
|
||||
equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
|
||||
assert.equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
|
||||
assert.equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
|
||||
} else {
|
||||
// need to have same number of assertions
|
||||
ok( true, "Fixed position is not supported" );
|
||||
ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
assert.ok( true, "Fixed position is not supported" );
|
||||
}
|
||||
});
|
||||
|
||||
testIframe("offset/table", "table", function( $ ) {
|
||||
expect(4);
|
||||
testIframe("offset/table", "table", function( $, window, document, assert ) {
|
||||
assert.expect(4);
|
||||
|
||||
equal( $("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
|
||||
equal( $("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
|
||||
assert.equal( $("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
|
||||
assert.equal( $("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
|
||||
|
||||
equal( $("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
|
||||
equal( $("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
|
||||
assert.equal( $("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
|
||||
assert.equal( $("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
|
||||
});
|
||||
|
||||
testIframe("offset/scroll", "scroll", function( $, win ) {
|
||||
expect( 30 );
|
||||
testIframe("offset/scroll", "scroll", function( $, win, doc, assert ) {
|
||||
assert.expect( 30 );
|
||||
|
||||
equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
|
||||
equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
assert.equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
|
||||
assert.equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
||||
|
||||
equal( $("#scroll-1-1").offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
equal( $("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
assert.equal( $("#scroll-1-1").offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
|
||||
assert.equal( $("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
||||
|
||||
// These tests are solely for master/compat consistency
|
||||
// Retrieving offset on disconnected/hidden elements is not officially
|
||||
// valid input, but will return zeros for back-compat
|
||||
equal( $("#hidden").offset().top, 0, "Hidden elements do not subtract scroll" );
|
||||
equal( $("#hidden").offset().left, 0, "Hidden elements do not subtract scroll" );
|
||||
assert.equal( $("#hidden").offset().top, 0, "Hidden elements do not subtract scroll" );
|
||||
assert.equal( $("#hidden").offset().left, 0, "Hidden elements do not subtract scroll" );
|
||||
|
||||
// scroll offset tests .scrollTop/Left
|
||||
equal( $("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
equal( $("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
assert.equal( $("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
||||
assert.equal( $("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
||||
|
||||
equal( $("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
||||
equal( $("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
||||
assert.equal( $("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
||||
assert.equal( $("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
||||
|
||||
// scroll method chaining
|
||||
equal( $("#scroll-1").scrollTop(undefined).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" );
|
||||
equal( $("#scroll-1").scrollLeft(undefined).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" );
|
||||
assert.equal( $("#scroll-1").scrollTop(undefined).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" );
|
||||
assert.equal( $("#scroll-1").scrollLeft(undefined).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" );
|
||||
|
||||
win.name = "test";
|
||||
|
||||
if ( !window.supportsScroll ) {
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
assert.ok( true, "Browser doesn't support scroll position." );
|
||||
} else {
|
||||
equal( $(win).scrollTop(), 1000, "jQuery(window).scrollTop()" );
|
||||
equal( $(win).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
|
||||
assert.equal( $(win).scrollTop(), 1000, "jQuery(window).scrollTop()" );
|
||||
assert.equal( $(win).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
|
||||
|
||||
equal( $(win.document).scrollTop(), 1000, "jQuery(document).scrollTop()" );
|
||||
equal( $(win.document).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
|
||||
assert.equal( $(win.document).scrollTop(), 1000, "jQuery(document).scrollTop()" );
|
||||
assert.equal( $(win.document).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
|
||||
}
|
||||
|
||||
// test jQuery using parent window/document
|
||||
// jQuery reference here is in the iframe
|
||||
window.scrollTo(0,0);
|
||||
equal( $(window).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
|
||||
equal( $(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
||||
equal( $(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
|
||||
equal( $(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
|
||||
assert.equal( $(window).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
|
||||
assert.equal( $(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
||||
assert.equal( $(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
|
||||
assert.equal( $(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
|
||||
|
||||
// Tests scrollTop/Left with empty jquery objects
|
||||
notEqual( $().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
notEqual( $().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
notEqual( $().scrollTop(null), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
|
||||
notEqual( $().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
||||
strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollTop(null), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
|
||||
assert.notEqual( $().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
||||
assert.strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
||||
assert.strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
||||
|
||||
// Tests position after parent scrolling (#15239)
|
||||
$("#scroll-1").scrollTop(0);
|
||||
$("#scroll-1").scrollLeft(0);
|
||||
equal( $("#scroll-1-1").position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
||||
equal( $("#scroll-1-1").position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
||||
assert.equal( $("#scroll-1-1").position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
||||
assert.equal( $("#scroll-1-1").position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
||||
|
||||
$("#scroll-1").scrollTop(5);
|
||||
$("#scroll-1").scrollLeft(5);
|
||||
equal( $("#scroll-1-1").position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
||||
equal( $("#scroll-1-1").position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
||||
assert.equal( $("#scroll-1-1").position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" );
|
||||
assert.equal( $("#scroll-1-1").position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" );
|
||||
});
|
||||
|
||||
testIframe("offset/body", "body", function( $ ) {
|
||||
expect(4);
|
||||
testIframe("offset/body", "body", function( $, window, document, assert ) {
|
||||
assert.expect(4);
|
||||
|
||||
equal( $("body").offset().top, 1, "jQuery('#body').offset().top" );
|
||||
equal( $("body").offset().left, 1, "jQuery('#body').offset().left" );
|
||||
equal( $("#firstElement").position().left, 5, "$('#firstElement').position().left" );
|
||||
equal( $("#firstElement").position().top, 5, "$('#firstElement').position().top" );
|
||||
assert.equal( $("body").offset().top, 1, "jQuery('#body').offset().top" );
|
||||
assert.equal( $("body").offset().left, 1, "jQuery('#body').offset().left" );
|
||||
assert.equal( $("#firstElement").position().left, 5, "$('#firstElement').position().left" );
|
||||
assert.equal( $("#firstElement").position().top, 5, "$('#firstElement').position().top" );
|
||||
});
|
||||
|
||||
test("chaining", function() {
|
||||
expect(3);
|
||||
QUnit.test("chaining", function( assert ) {
|
||||
assert.expect(3);
|
||||
var coords = { "top": 1, "left": 1 };
|
||||
equal( jQuery("#absolute-1").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
|
||||
equal( jQuery("#non-existent").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
|
||||
equal( jQuery("#absolute-1").offset(undefined).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" );
|
||||
assert.equal( jQuery("#absolute-1").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" );
|
||||
assert.equal( jQuery("#non-existent").offset(coords).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" );
|
||||
assert.equal( jQuery("#absolute-1").offset(undefined).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" );
|
||||
});
|
||||
|
||||
test("offsetParent", function(){
|
||||
expect(13);
|
||||
QUnit.test("offsetParent", function( assert ){
|
||||
assert.expect(13);
|
||||
|
||||
var body, header, div, area;
|
||||
|
||||
body = jQuery("body").offsetParent();
|
||||
equal( body.length, 1, "Only one offsetParent found." );
|
||||
equal( body[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
assert.equal( body.length, 1, "Only one offsetParent found." );
|
||||
assert.equal( body[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
|
||||
header = jQuery("#qunit").offsetParent();
|
||||
equal( header.length, 1, "Only one offsetParent found." );
|
||||
equal( header[0], document.documentElement, "The html element is the offsetParent of #qunit." );
|
||||
assert.equal( header.length, 1, "Only one offsetParent found." );
|
||||
assert.equal( header[0], document.documentElement, "The html element is the offsetParent of #qunit." );
|
||||
|
||||
div = jQuery("#nothiddendivchild").offsetParent();
|
||||
equal( div.length, 1, "Only one offsetParent found." );
|
||||
equal( div[0], document.getElementById("qunit-fixture"), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
|
||||
assert.equal( div.length, 1, "Only one offsetParent found." );
|
||||
assert.equal( div[0], document.getElementById("qunit-fixture"), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
|
||||
|
||||
jQuery("#nothiddendiv").css("position", "relative");
|
||||
|
||||
div = jQuery("#nothiddendivchild").offsetParent();
|
||||
equal( div.length, 1, "Only one offsetParent found." );
|
||||
equal( div[0], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
||||
assert.equal( div.length, 1, "Only one offsetParent found." );
|
||||
assert.equal( div[0], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
||||
|
||||
div = jQuery("body, #nothiddendivchild").offsetParent();
|
||||
equal( div.length, 2, "Two offsetParent found." );
|
||||
equal( div[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
equal( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
||||
assert.equal( div.length, 2, "Two offsetParent found." );
|
||||
assert.equal( div[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
assert.equal( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
||||
|
||||
area = jQuery("#imgmap area").offsetParent();
|
||||
equal( area[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
assert.equal( area[0], document.documentElement, "The html element is the offsetParent of the body." );
|
||||
|
||||
div = jQuery("<div>").css({ "position": "absolute" }).appendTo("body");
|
||||
equal( div.offsetParent()[0], document.documentElement, "Absolutely positioned div returns html as offset parent, see #12139" );
|
||||
assert.equal( div.offsetParent()[0], document.documentElement, "Absolutely positioned div returns html as offset parent, see #12139" );
|
||||
|
||||
div.remove();
|
||||
});
|
||||
|
||||
test("fractions (see #7730 and #7885)", function() {
|
||||
expect(2);
|
||||
QUnit.test("fractions (see #7730 and #7885)", function( assert ) {
|
||||
assert.expect(2);
|
||||
|
||||
jQuery("body").append("<div id='fractions'/>");
|
||||
|
||||
@ -551,14 +551,14 @@ test("fractions (see #7730 and #7885)", function() {
|
||||
|
||||
result = div.offset();
|
||||
|
||||
equal( result.top, expected.top, "Check top" );
|
||||
equal( result.left, expected.left, "Check left" );
|
||||
assert.equal( result.top, expected.top, "Check top" );
|
||||
assert.equal( result.left, expected.left, "Check left" );
|
||||
|
||||
div.remove();
|
||||
});
|
||||
|
||||
test("iframe scrollTop/Left (see gh-1945)", function() {
|
||||
expect( 2 );
|
||||
QUnit.test("iframe scrollTop/Left (see gh-1945)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var ifDoc = jQuery( "#iframe" )[ 0 ].contentDocument;
|
||||
|
||||
@ -568,8 +568,8 @@ test("iframe scrollTop/Left (see gh-1945)", function() {
|
||||
if ( /iphone os/i.test( navigator.userAgent ) ||
|
||||
/android 2\.3/i.test( navigator.userAgent ) ||
|
||||
/android 4\.0/i.test( navigator.userAgent ) ) {
|
||||
equal( true, true, "Can't scroll iframes in this environment" );
|
||||
equal( true, true, "Can't scroll iframes in this environment" );
|
||||
assert.equal( true, true, "Can't scroll iframes in this environment" );
|
||||
assert.equal( true, true, "Can't scroll iframes in this environment" );
|
||||
|
||||
} else {
|
||||
// Tests scrollTop/Left with iframes
|
||||
@ -579,8 +579,8 @@ test("iframe scrollTop/Left (see gh-1945)", function() {
|
||||
jQuery( ifDoc ).scrollTop( 200 );
|
||||
jQuery( ifDoc ).scrollLeft( 500 );
|
||||
|
||||
equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" );
|
||||
equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" );
|
||||
assert.equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" );
|
||||
assert.equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" );
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,155 +1,155 @@
|
||||
module( "queue", { teardown: moduleTeardown });
|
||||
QUnit.module( "queue", { teardown: moduleTeardown });
|
||||
|
||||
test( "queue() with other types", function() {
|
||||
expect( 14 );
|
||||
QUnit.test( "queue() with other types", function( assert ) {
|
||||
assert.expect( 14 );
|
||||
|
||||
stop();
|
||||
QUnit.stop();
|
||||
|
||||
var $div = jQuery({}),
|
||||
counter = 0;
|
||||
|
||||
$div.promise( "foo" ).done(function() {
|
||||
equal( counter, 0, "Deferred for collection with no queue is automatically resolved" );
|
||||
assert.equal( counter, 0, "Deferred for collection with no queue is automatically resolved" );
|
||||
});
|
||||
|
||||
$div
|
||||
.queue("foo",function(){
|
||||
equal( ++counter, 1, "Dequeuing" );
|
||||
assert.equal( ++counter, 1, "Dequeuing" );
|
||||
jQuery.dequeue(this,"foo");
|
||||
})
|
||||
.queue("foo",function(){
|
||||
equal( ++counter, 2, "Dequeuing" );
|
||||
assert.equal( ++counter, 2, "Dequeuing" );
|
||||
jQuery(this).dequeue("foo");
|
||||
})
|
||||
.queue("foo",function(){
|
||||
equal( ++counter, 3, "Dequeuing" );
|
||||
assert.equal( ++counter, 3, "Dequeuing" );
|
||||
})
|
||||
.queue("foo",function(){
|
||||
equal( ++counter, 4, "Dequeuing" );
|
||||
assert.equal( ++counter, 4, "Dequeuing" );
|
||||
});
|
||||
|
||||
$div.promise("foo").done(function() {
|
||||
equal( counter, 4, "Testing previous call to dequeue in deferred" );
|
||||
start();
|
||||
assert.equal( counter, 4, "Testing previous call to dequeue in deferred" );
|
||||
QUnit.start();
|
||||
});
|
||||
|
||||
equal( $div.queue("foo").length, 4, "Testing queue length" );
|
||||
assert.equal( $div.queue("foo").length, 4, "Testing queue length" );
|
||||
|
||||
equal( $div.queue("foo", undefined).queue("foo").length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)");
|
||||
assert.equal( $div.queue("foo", undefined).queue("foo").length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)");
|
||||
|
||||
$div.dequeue("foo");
|
||||
|
||||
equal( counter, 3, "Testing previous call to dequeue" );
|
||||
equal( $div.queue("foo").length, 1, "Testing queue length" );
|
||||
assert.equal( counter, 3, "Testing previous call to dequeue" );
|
||||
assert.equal( $div.queue("foo").length, 1, "Testing queue length" );
|
||||
|
||||
$div.dequeue("foo");
|
||||
|
||||
equal( counter, 4, "Testing previous call to dequeue" );
|
||||
equal( $div.queue("foo").length, 0, "Testing queue length" );
|
||||
assert.equal( counter, 4, "Testing previous call to dequeue" );
|
||||
assert.equal( $div.queue("foo").length, 0, "Testing queue length" );
|
||||
|
||||
$div.dequeue("foo");
|
||||
|
||||
equal( counter, 4, "Testing previous call to dequeue" );
|
||||
equal( $div.queue("foo").length, 0, "Testing queue length" );
|
||||
assert.equal( counter, 4, "Testing previous call to dequeue" );
|
||||
assert.equal( $div.queue("foo").length, 0, "Testing queue length" );
|
||||
|
||||
});
|
||||
|
||||
test("queue(name) passes in the next item in the queue as a parameter", function() {
|
||||
expect(2);
|
||||
QUnit.test("queue(name) passes in the next item in the queue as a parameter", function( assert ) {
|
||||
assert.expect(2);
|
||||
|
||||
var div = jQuery({}),
|
||||
counter = 0;
|
||||
|
||||
div.queue("foo", function(next) {
|
||||
equal(++counter, 1, "Dequeueing");
|
||||
assert.equal(++counter, 1, "Dequeueing");
|
||||
next();
|
||||
}).queue("foo", function(next) {
|
||||
equal(++counter, 2, "Next was called");
|
||||
assert.equal(++counter, 2, "Next was called");
|
||||
next();
|
||||
}).queue("bar", function() {
|
||||
equal(++counter, 3, "Other queues are not triggered by next()");
|
||||
assert.equal(++counter, 3, "Other queues are not triggered by next()");
|
||||
});
|
||||
|
||||
div.dequeue("foo");
|
||||
});
|
||||
|
||||
test("queue() passes in the next item in the queue as a parameter to fx queues", function() {
|
||||
expect(3);
|
||||
stop();
|
||||
QUnit.test("queue() passes in the next item in the queue as a parameter to fx queues", function( assert ) {
|
||||
assert.expect(3);
|
||||
QUnit.stop();
|
||||
|
||||
var div = jQuery({}),
|
||||
counter = 0;
|
||||
|
||||
div.queue(function(next) {
|
||||
equal(++counter, 1, "Dequeueing");
|
||||
assert.equal(++counter, 1, "Dequeueing");
|
||||
setTimeout(function() { next(); }, 500);
|
||||
}).queue(function(next) {
|
||||
equal(++counter, 2, "Next was called");
|
||||
assert.equal(++counter, 2, "Next was called");
|
||||
next();
|
||||
}).queue("bar", function() {
|
||||
equal(++counter, 3, "Other queues are not triggered by next()");
|
||||
assert.equal(++counter, 3, "Other queues are not triggered by next()");
|
||||
});
|
||||
|
||||
jQuery.when( div.promise("fx"), div ).done(function() {
|
||||
equal(counter, 2, "Deferreds resolved");
|
||||
start();
|
||||
assert.equal(counter, 2, "Deferreds resolved");
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
|
||||
test("callbacks keep their place in the queue", function() {
|
||||
expect(5);
|
||||
stop();
|
||||
QUnit.test("callbacks keep their place in the queue", function( assert ) {
|
||||
assert.expect(5);
|
||||
QUnit.stop();
|
||||
var div = jQuery("<div>"),
|
||||
counter = 0;
|
||||
|
||||
div.queue(function( next ) {
|
||||
equal( ++counter, 1, "Queue/callback order: first called" );
|
||||
assert.equal( ++counter, 1, "Queue/callback order: first called" );
|
||||
setTimeout( next, 200 );
|
||||
}).delay( 100 ).queue(function( next ) {
|
||||
equal( ++counter, 2, "Queue/callback order: second called" );
|
||||
assert.equal( ++counter, 2, "Queue/callback order: second called" );
|
||||
jQuery( this ).delay( 100 ).queue(function( next ) {
|
||||
equal( ++counter, 4, "Queue/callback order: fourth called" );
|
||||
assert.equal( ++counter, 4, "Queue/callback order: fourth called" );
|
||||
next();
|
||||
});
|
||||
next();
|
||||
}).queue(function( next ) {
|
||||
equal( ++counter, 3, "Queue/callback order: third called" );
|
||||
assert.equal( ++counter, 3, "Queue/callback order: third called" );
|
||||
next();
|
||||
});
|
||||
|
||||
div.promise("fx").done(function() {
|
||||
equal(counter, 4, "Deferreds resolved");
|
||||
start();
|
||||
assert.equal(counter, 4, "Deferreds resolved");
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
|
||||
test( "jQuery.queue should return array while manipulating the queue", function() {
|
||||
expect( 1 );
|
||||
QUnit.test( "jQuery.queue should return array while manipulating the queue", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var div = document.createElement("div");
|
||||
|
||||
ok( jQuery.isArray( jQuery.queue( div, "fx", jQuery.noop ) ), "jQuery.queue should return an array while manipulating the queue" );
|
||||
assert.ok( jQuery.isArray( jQuery.queue( div, "fx", jQuery.noop ) ), "jQuery.queue should return an array while manipulating the queue" );
|
||||
});
|
||||
|
||||
test("delay()", function() {
|
||||
expect(2);
|
||||
stop();
|
||||
QUnit.test("delay()", function( assert ) {
|
||||
assert.expect(2);
|
||||
QUnit.stop();
|
||||
|
||||
var foo = jQuery({}), run = 0;
|
||||
|
||||
foo.delay(100).queue(function(){
|
||||
run = 1;
|
||||
ok( true, "The function was dequeued." );
|
||||
start();
|
||||
assert.ok( true, "The function was dequeued." );
|
||||
QUnit.start();
|
||||
});
|
||||
|
||||
equal( run, 0, "The delay delayed the next function from running." );
|
||||
assert.equal( run, 0, "The delay delayed the next function from running." );
|
||||
});
|
||||
|
||||
test("clearQueue(name) clears the queue", function() {
|
||||
expect(2);
|
||||
QUnit.test("clearQueue(name) clears the queue", function( assert ) {
|
||||
assert.expect(2);
|
||||
|
||||
stop();
|
||||
QUnit.stop();
|
||||
|
||||
var div = jQuery({}),
|
||||
counter = 0;
|
||||
@ -163,17 +163,17 @@ test("clearQueue(name) clears the queue", function() {
|
||||
});
|
||||
|
||||
div.promise("foo").done(function() {
|
||||
ok( true, "dequeue resolves the deferred" );
|
||||
start();
|
||||
assert.ok( true, "dequeue resolves the deferred" );
|
||||
QUnit.start();
|
||||
});
|
||||
|
||||
div.dequeue("foo");
|
||||
|
||||
equal(counter, 1, "the queue was cleared");
|
||||
assert.equal(counter, 1, "the queue was cleared");
|
||||
});
|
||||
|
||||
test("clearQueue() clears the fx queue", function() {
|
||||
expect(1);
|
||||
QUnit.test("clearQueue() clears the fx queue", function( assert ) {
|
||||
assert.expect(1);
|
||||
|
||||
var div = jQuery({}),
|
||||
counter = 0;
|
||||
@ -186,51 +186,51 @@ test("clearQueue() clears the fx queue", function() {
|
||||
counter++;
|
||||
});
|
||||
|
||||
equal(counter, 1, "the queue was cleared");
|
||||
assert.equal(counter, 1, "the queue was cleared");
|
||||
|
||||
div.removeData();
|
||||
});
|
||||
|
||||
asyncTest( "fn.promise() - called when fx queue is empty", 3, function() {
|
||||
QUnit.asyncTest( "fn.promise() - called when fx queue is empty", 3, function( assert ) {
|
||||
var foo = jQuery( "#foo" ).clone().addBack(),
|
||||
promised = false;
|
||||
|
||||
foo.queue( function( next ) {
|
||||
// called twice!
|
||||
ok( !promised, "Promised hasn't been called" );
|
||||
assert.ok( !promised, "Promised hasn't been called" );
|
||||
setTimeout( next, 10 );
|
||||
});
|
||||
foo.promise().done( function() {
|
||||
ok( promised = true, "Promised" );
|
||||
start();
|
||||
assert.ok( promised = true, "Promised" );
|
||||
QUnit.start();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", 5, function() {
|
||||
QUnit.asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", 5, function( assert ) {
|
||||
var foo = jQuery( "#foo" ),
|
||||
test;
|
||||
foo.promise( "queue" ).done( function() {
|
||||
strictEqual( test, undefined, "called immediately when queue was already empty" );
|
||||
assert.strictEqual( test, undefined, "called immediately when queue was already empty" );
|
||||
});
|
||||
test = 1;
|
||||
foo.queue( "queue", function( next ) {
|
||||
strictEqual( test++, 1, "step one" );
|
||||
assert.strictEqual( test++, 1, "step one" );
|
||||
setTimeout( next, 0 );
|
||||
}).queue( "queue", function( next ) {
|
||||
strictEqual( test++, 2, "step two" );
|
||||
assert.strictEqual( test++, 2, "step two" );
|
||||
setTimeout( function() {
|
||||
next();
|
||||
strictEqual( test++, 4, "step four" );
|
||||
start();
|
||||
assert.strictEqual( test++, 4, "step four" );
|
||||
QUnit.start();
|
||||
}, 10 );
|
||||
}).promise( "queue" ).done( function() {
|
||||
strictEqual( test++, 3, "step three" );
|
||||
assert.strictEqual( test++, 3, "step three" );
|
||||
});
|
||||
|
||||
foo.dequeue( "queue" );
|
||||
});
|
||||
|
||||
asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function() {
|
||||
QUnit.asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function( assert ) {
|
||||
var foo = jQuery( "#foo" ),
|
||||
test = 1;
|
||||
|
||||
@ -240,44 +240,44 @@ asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before res
|
||||
duration: 1,
|
||||
queue: "queue",
|
||||
complete: function() {
|
||||
strictEqual( test++, 1, "step one" );
|
||||
assert.strictEqual( test++, 1, "step one" );
|
||||
}
|
||||
}).dequeue( "queue" );
|
||||
|
||||
foo.promise( "queue" ).done( function() {
|
||||
strictEqual( test++, 2, "step two" );
|
||||
start();
|
||||
assert.strictEqual( test++, 2, "step two" );
|
||||
QUnit.start();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test( ".promise(obj)", function() {
|
||||
expect(2);
|
||||
QUnit.test( ".promise(obj)", function( assert ) {
|
||||
assert.expect(2);
|
||||
|
||||
var obj = {},
|
||||
promise = jQuery( "#foo" ).promise( "promise", obj );
|
||||
|
||||
ok( jQuery.isFunction( promise.promise ), ".promise(type, obj) returns a promise" );
|
||||
strictEqual( promise, obj, ".promise(type, obj) returns obj" );
|
||||
assert.ok( jQuery.isFunction( promise.promise ), ".promise(type, obj) returns a promise" );
|
||||
assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" );
|
||||
});
|
||||
|
||||
|
||||
if ( jQuery.fn.stop ) {
|
||||
test("delay() can be stopped", function() {
|
||||
expect( 3 );
|
||||
stop();
|
||||
QUnit.test("delay() can be stopped", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
QUnit.stop();
|
||||
|
||||
var done = {};
|
||||
jQuery({})
|
||||
.queue( "alternate", function( next ) {
|
||||
done.alt1 = true;
|
||||
ok( true, "This first function was dequeued" );
|
||||
assert.ok( true, "This first function was dequeued" );
|
||||
next();
|
||||
})
|
||||
.delay( 1000, "alternate" )
|
||||
.queue( "alternate", function() {
|
||||
done.alt2 = true;
|
||||
ok( true, "The function was dequeued immediately, the delay was stopped" );
|
||||
assert.ok( true, "The function was dequeued immediately, the delay was stopped" );
|
||||
})
|
||||
.dequeue( "alternate" )
|
||||
|
||||
@ -288,33 +288,33 @@ if ( jQuery.fn.stop ) {
|
||||
.delay( 1 )
|
||||
.queue(function() {
|
||||
done.default1 = true;
|
||||
ok( false, "This queue should never run" );
|
||||
assert.ok( false, "This queue should never run" );
|
||||
})
|
||||
|
||||
// stop( clearQueue ) should clear the queue
|
||||
.stop( true, false );
|
||||
|
||||
deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" );
|
||||
assert.deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" );
|
||||
|
||||
setTimeout(function() {
|
||||
start();
|
||||
QUnit.start();
|
||||
}, 1500 );
|
||||
});
|
||||
|
||||
asyncTest( "queue stop hooks", 2, function() {
|
||||
QUnit.asyncTest( "queue stop hooks", 2, function( assert ) {
|
||||
var foo = jQuery( "#foo" );
|
||||
|
||||
foo.queue( function( next, hooks ) {
|
||||
hooks.stop = function( gotoEnd ) {
|
||||
equal( !!gotoEnd, false, "Stopped without gotoEnd" );
|
||||
assert.equal( !!gotoEnd, false, "Stopped without gotoEnd" );
|
||||
};
|
||||
});
|
||||
foo.stop();
|
||||
|
||||
foo.queue( function( next, hooks ) {
|
||||
hooks.stop = function( gotoEnd ) {
|
||||
equal( gotoEnd, true, "Stopped with gotoEnd" );
|
||||
start();
|
||||
assert.equal( gotoEnd, true, "Stopped with gotoEnd" );
|
||||
QUnit.start();
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
module( "event" );
|
||||
QUnit.module( "event" );
|
||||
|
||||
(function() {
|
||||
var notYetReady, noEarlyExecution,
|
||||
@ -7,11 +7,11 @@ module( "event" );
|
||||
|
||||
notYetReady = !jQuery.isReady;
|
||||
|
||||
test( "jQuery.isReady", function() {
|
||||
expect( 2 );
|
||||
QUnit.test( "jQuery.isReady", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
equal( notYetReady, true, "jQuery.isReady should not be true before DOM ready" );
|
||||
equal( jQuery.isReady, true, "jQuery.isReady should be true once DOM is ready" );
|
||||
assert.equal( notYetReady, true, "jQuery.isReady should not be true before DOM ready" );
|
||||
assert.equal( jQuery.isReady, true, "jQuery.isReady should be true once DOM is ready" );
|
||||
});
|
||||
|
||||
// Create an event handler.
|
||||
@ -37,20 +37,20 @@ module( "event" );
|
||||
noEarlyExecution = order.length === 0;
|
||||
|
||||
// This assumes that QUnit tests are run on DOM ready!
|
||||
test( "jQuery ready", function() {
|
||||
expect( 8 );
|
||||
QUnit.test( "jQuery ready", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
|
||||
ok( noEarlyExecution,
|
||||
assert.ok( noEarlyExecution,
|
||||
"Handlers bound to DOM ready should not execute before DOM ready" );
|
||||
|
||||
// Ensure execution order.
|
||||
deepEqual( order, [ "a", "b", "c", "d" ],
|
||||
assert.deepEqual( order, [ "a", "b", "c", "d" ],
|
||||
"Bound DOM ready handlers should execute in on-order" );
|
||||
|
||||
// Ensure handler argument is correct.
|
||||
equal( args.a, jQuery,
|
||||
assert.equal( args.a, jQuery,
|
||||
"Argument passed to fn in jQuery( fn ) should be jQuery" );
|
||||
equal( args.b, jQuery,
|
||||
assert.equal( args.b, jQuery,
|
||||
"Argument passed to fn in jQuery(document).ready( fn ) should be jQuery" );
|
||||
|
||||
order = [];
|
||||
@ -58,12 +58,12 @@ module( "event" );
|
||||
// Now that the ready event has fired, again bind to the ready event
|
||||
// in every possible way. These event handlers should execute immediately.
|
||||
jQuery( makeHandler( "g" ) );
|
||||
equal( order.pop(), "g", "Event handler should execute immediately" );
|
||||
equal( args.g, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery" );
|
||||
assert.equal( order.pop(), "g", "Event handler should execute immediately" );
|
||||
assert.equal( args.g, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery" );
|
||||
|
||||
jQuery( document ).ready( makeHandler( "h" ) );
|
||||
equal( order.pop(), "h", "Event handler should execute immediately" );
|
||||
equal( args.h, jQuery,
|
||||
assert.equal( order.pop(), "h", "Event handler should execute immediately" );
|
||||
assert.equal( args.h, jQuery,
|
||||
"Argument passed to fn in jQuery(document).ready( fn ) should be jQuery" );
|
||||
});
|
||||
|
||||
|
@ -1,28 +1,28 @@
|
||||
module("selector", { teardown: moduleTeardown });
|
||||
QUnit.module("selector", { teardown: moduleTeardown });
|
||||
|
||||
/**
|
||||
* This test page is for selector tests that require jQuery in order to do the selection
|
||||
*/
|
||||
|
||||
test("element - jQuery only", function() {
|
||||
expect( 7 );
|
||||
QUnit.test("element - jQuery only", function( assert ) {
|
||||
assert.expect( 7 );
|
||||
|
||||
var fixture = document.getElementById("qunit-fixture");
|
||||
|
||||
deepEqual( jQuery("p", fixture).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a Node context." );
|
||||
deepEqual( jQuery("p", "#qunit-fixture").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a selector context." );
|
||||
deepEqual( jQuery("p", jQuery("#qunit-fixture")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a jQuery object context." );
|
||||
deepEqual( jQuery("#qunit-fixture").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context via .find()." );
|
||||
assert.deepEqual( jQuery("p", fixture).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a Node context." );
|
||||
assert.deepEqual( jQuery("p", "#qunit-fixture").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a selector context." );
|
||||
assert.deepEqual( jQuery("p", jQuery("#qunit-fixture")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a jQuery object context." );
|
||||
assert.deepEqual( jQuery("#qunit-fixture").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context via .find()." );
|
||||
|
||||
ok( jQuery("#length").length, "<input name=\"length\"> cannot be found under IE, see #945" );
|
||||
ok( jQuery("#lengthtest input").length, "<input name=\"length\"> cannot be found under IE, see #945" );
|
||||
assert.ok( jQuery("#length").length, "<input name=\"length\"> cannot be found under IE, see #945" );
|
||||
assert.ok( jQuery("#lengthtest input").length, "<input name=\"length\"> cannot be found under IE, see #945" );
|
||||
|
||||
// #7533
|
||||
equal( jQuery("<div id=\"A'B~C.D[E]\"><p>foo</p></div>").find("p").length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" );
|
||||
assert.equal( jQuery("<div id=\"A'B~C.D[E]\"><p>foo</p></div>").find("p").length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" );
|
||||
});
|
||||
|
||||
test("id", function() {
|
||||
expect( 26 );
|
||||
QUnit.test("id", function( assert ) {
|
||||
assert.expect( 26 );
|
||||
|
||||
var a;
|
||||
|
||||
@ -63,17 +63,17 @@ test("id", function() {
|
||||
t( "ID with weird characters in it", "#name\\+value", ["name+value"] );
|
||||
});
|
||||
|
||||
test("class - jQuery only", function() {
|
||||
expect( 4 );
|
||||
QUnit.test("class - jQuery only", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
deepEqual( jQuery(".blog", document.getElementsByTagName("p")).get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
deepEqual( jQuery(".blog", "p").get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
deepEqual( jQuery(".blog", jQuery("p")).get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
deepEqual( jQuery("p").find(".blog").get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery(".blog", document.getElementsByTagName("p")).get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery(".blog", "p").get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery(".blog", jQuery("p")).get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
assert.deepEqual( jQuery("p").find(".blog").get(), q("mark", "simon"), "Finding elements with a context." );
|
||||
});
|
||||
|
||||
test("name", function() {
|
||||
expect( 5 );
|
||||
QUnit.test("name", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var form;
|
||||
|
||||
@ -84,24 +84,24 @@ test("name", function() {
|
||||
t( "Name selector for grouped input", "input[name='types[]']", ["types_all", "types_anime", "types_movie"] );
|
||||
|
||||
form = jQuery("<form><input name='id'/></form>").appendTo("body");
|
||||
equal( jQuery("input", form[0]).length, 1, "Make sure that rooted queries on forms (with possible expandos) work." );
|
||||
assert.equal( jQuery("input", form[0]).length, 1, "Make sure that rooted queries on forms (with possible expandos) work." );
|
||||
|
||||
form.remove();
|
||||
});
|
||||
|
||||
test( "selectors with comma", function() {
|
||||
expect( 4 );
|
||||
QUnit.test( "selectors with comma", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var fixture = jQuery( "<div><h2><span/></h2><div><p><span/></p><p/></div></div>" );
|
||||
|
||||
equal( fixture.find( "h2, div p" ).filter( "p" ).length, 2, "has to find two <p>" );
|
||||
equal( fixture.find( "h2, div p" ).filter( "h2" ).length, 1, "has to find one <h2>" );
|
||||
equal( fixture.find( "h2 , div p" ).filter( "p" ).length, 2, "has to find two <p>" );
|
||||
equal( fixture.find( "h2 , div p" ).filter( "h2" ).length, 1, "has to find one <h2>" );
|
||||
assert.equal( fixture.find( "h2, div p" ).filter( "p" ).length, 2, "has to find two <p>" );
|
||||
assert.equal( fixture.find( "h2, div p" ).filter( "h2" ).length, 1, "has to find one <h2>" );
|
||||
assert.equal( fixture.find( "h2 , div p" ).filter( "p" ).length, 2, "has to find two <p>" );
|
||||
assert.equal( fixture.find( "h2 , div p" ).filter( "h2" ).length, 1, "has to find one <h2>" );
|
||||
});
|
||||
|
||||
test( "child and adjacent", function() {
|
||||
expect( 27 );
|
||||
QUnit.test( "child and adjacent", function( assert ) {
|
||||
assert.expect( 27 );
|
||||
|
||||
var nothiddendiv;
|
||||
|
||||
@ -127,10 +127,10 @@ test( "child and adjacent", function() {
|
||||
t( "Multiple sibling combinators doesn't miss general siblings", "#siblingTest > em:first-child + em ~ span", ["siblingspan"] );
|
||||
t( "Combinators are not skipped when mixing general and specific", "#siblingTest > em:contains('x') + em ~ span", [] );
|
||||
|
||||
equal( jQuery("#listWithTabIndex").length, 1, "Parent div for next test is found via ID (#8310)" );
|
||||
equal( jQuery("#listWithTabIndex li:eq(2) ~ li").length, 1, "Find by general sibling combinator (#8310)" );
|
||||
equal( jQuery("#__sizzle__").length, 0, "Make sure the temporary id assigned by sizzle is cleared out (#8310)" );
|
||||
equal( jQuery("#listWithTabIndex").length, 1, "Parent div for previous test is still found via ID (#8310)" );
|
||||
assert.equal( jQuery("#listWithTabIndex").length, 1, "Parent div for next test is found via ID (#8310)" );
|
||||
assert.equal( jQuery("#listWithTabIndex li:eq(2) ~ li").length, 1, "Find by general sibling combinator (#8310)" );
|
||||
assert.equal( jQuery("#__sizzle__").length, 0, "Make sure the temporary id assigned by sizzle is cleared out (#8310)" );
|
||||
assert.equal( jQuery("#listWithTabIndex").length, 1, "Parent div for previous test is still found via ID (#8310)" );
|
||||
|
||||
t( "Verify deep class selector", "div.blah > p > a", [] );
|
||||
|
||||
@ -141,8 +141,8 @@ test( "child and adjacent", function() {
|
||||
t( "Non-existent ancestors", ".fototab > .thumbnails > a", [] );
|
||||
});
|
||||
|
||||
test("attributes", function() {
|
||||
expect( 54 );
|
||||
QUnit.test("attributes", function( assert ) {
|
||||
assert.expect( 54 );
|
||||
|
||||
var attrbad, div, withScript;
|
||||
|
||||
@ -221,7 +221,7 @@ test("attributes", function() {
|
||||
t( "input[type=search]", "#form input[type=search]", ["search"] );
|
||||
|
||||
withScript = supportjQuery( "<div><span><script src=''/></span></div>" );
|
||||
ok( withScript.find( "#moretests script[src]" ).has( "script" ), "script[src] (jQuery #13777)" );
|
||||
assert.ok( withScript.find( "#moretests script[src]" ).has( "script" ), "script[src] (jQuery #13777)" );
|
||||
|
||||
div = document.getElementById("foo");
|
||||
t( "Object.prototype property \"constructor\" (negative)", "[constructor]", [] );
|
||||
@ -234,160 +234,164 @@ test("attributes", function() {
|
||||
t( "Value attribute is retrieved correctly", "input[value=Test]", ["text1", "text2"] );
|
||||
|
||||
// #12600
|
||||
ok(
|
||||
assert.ok(
|
||||
jQuery("<select value='12600'><option value='option' selected='selected'></option><option value=''></option></select>")
|
||||
.prop( "value", "option" )
|
||||
.is(":input[value='12600']"),
|
||||
|
||||
":input[value=foo] selects select by attribute"
|
||||
);
|
||||
ok( jQuery("<input type='text' value='12600'/>").prop( "value", "option" ).is(":input[value='12600']"),
|
||||
assert.ok( jQuery("<input type='text' value='12600'/>").prop( "value", "option" ).is(":input[value='12600']"),
|
||||
":input[value=foo] selects text input by attribute"
|
||||
);
|
||||
|
||||
// #11115
|
||||
ok( jQuery("<input type='checkbox' checked='checked'/>").prop( "checked", false ).is("[checked]"),
|
||||
assert.ok( jQuery("<input type='checkbox' checked='checked'/>").prop( "checked", false ).is("[checked]"),
|
||||
"[checked] selects by attribute (positive)"
|
||||
);
|
||||
ok( !jQuery("<input type='checkbox'/>").prop( "checked", true ).is("[checked]"),
|
||||
assert.ok( !jQuery("<input type='checkbox'/>").prop( "checked", true ).is("[checked]"),
|
||||
"[checked] selects by attribute (negative)"
|
||||
);
|
||||
});
|
||||
|
||||
test("disconnected nodes", function() {
|
||||
expect( 1 );
|
||||
QUnit.test("disconnected nodes", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
|
||||
var $div = jQuery("<div/>");
|
||||
equal( $div.is("div"), true, "Make sure .is('nodeName') works on disconnected nodes." );
|
||||
assert.equal( $div.is("div"), true, "Make sure .is('nodeName') works on disconnected nodes." );
|
||||
});
|
||||
|
||||
test("disconnected nodes - jQuery only", function() {
|
||||
expect( 3 );
|
||||
QUnit.test("disconnected nodes - jQuery only", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var $opt = jQuery("<option></option>").attr("value", "whipit").appendTo("#qunit-fixture").detach();
|
||||
equal( $opt.val(), "whipit", "option value" );
|
||||
equal( $opt.is(":selected"), false, "unselected option" );
|
||||
assert.equal( $opt.val(), "whipit", "option value" );
|
||||
assert.equal( $opt.is(":selected"), false, "unselected option" );
|
||||
$opt.prop("selected", true);
|
||||
equal( $opt.is(":selected"), true, "selected option" );
|
||||
assert.equal( $opt.is(":selected"), true, "selected option" );
|
||||
});
|
||||
|
||||
testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) {
|
||||
expect( 38 );
|
||||
testIframe(
|
||||
"selector/html5_selector",
|
||||
"attributes - jQuery.attr",
|
||||
function( jQuery, window, document, assert ) {
|
||||
assert.expect( 38 );
|
||||
|
||||
/**
|
||||
* Returns an array of elements with the given IDs
|
||||
* q & t are added here for the iFrame's context
|
||||
*/
|
||||
function q() {
|
||||
var r = [],
|
||||
i = 0;
|
||||
/**
|
||||
* Returns an array of elements with the given IDs
|
||||
* q & t are added here for the iFrame's context
|
||||
*/
|
||||
function q() {
|
||||
var r = [],
|
||||
i = 0;
|
||||
|
||||
for ( ; i < arguments.length; i++ ) {
|
||||
r.push( document.getElementById( arguments[i] ) );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a select matches the given IDs
|
||||
* @example t("Check for something", "//[a]", ["foo", "baar"]);
|
||||
* @param {String} a - Assertion name
|
||||
* @param {String} b - Sizzle selector
|
||||
* @param {Array} c - Array of ids to construct what is expected
|
||||
*/
|
||||
function t( a, b, c ) {
|
||||
var f = jQuery(b).get(),
|
||||
s = "",
|
||||
i = 0;
|
||||
|
||||
for ( ; i < f.length; i++ ) {
|
||||
s += (s && ",") + "'" + f[i].id + "'";
|
||||
for ( ; i < arguments.length; i++ ) {
|
||||
r.push( document.getElementById( arguments[i] ) );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
|
||||
/**
|
||||
* Asserts that a select matches the given IDs
|
||||
* @example t("Check for something", "//[a]", ["foo", "baar"]);
|
||||
* @param {String} a - Assertion name
|
||||
* @param {String} b - Sizzle selector
|
||||
* @param {Array} c - Array of ids to construct what is expected
|
||||
*/
|
||||
function t( a, b, c ) {
|
||||
var f = jQuery(b).get(),
|
||||
s = "",
|
||||
i = 0;
|
||||
|
||||
for ( ; i < f.length; i++ ) {
|
||||
s += (s && ",") + "'" + f[i].id + "'";
|
||||
}
|
||||
|
||||
assert.deepEqual(f, q.apply( q, c ), a + " (" + b + ")");
|
||||
}
|
||||
|
||||
// ====== All known boolean attributes, including html5 booleans ======
|
||||
// autobuffer, autofocus, autoplay, async, checked,
|
||||
// compact, controls, declare, defer, disabled,
|
||||
// formnovalidate, hidden, indeterminate (property only),
|
||||
// ismap, itemscope, loop, multiple, muted, nohref, noresize,
|
||||
// noshade, nowrap, novalidate, open, pubdate, readonly, required,
|
||||
// reversed, scoped, seamless, selected, truespeed, visible (skipping visible attribute, which is on a barprop object)
|
||||
|
||||
t( "Attribute Exists", "[autobuffer]", ["video1"]);
|
||||
t( "Attribute Exists", "[autofocus]", ["text1"]);
|
||||
t( "Attribute Exists", "[autoplay]", ["video1"]);
|
||||
t( "Attribute Exists", "[async]", ["script1"]);
|
||||
t( "Attribute Exists", "[checked]", ["check1"]);
|
||||
t( "Attribute Exists", "[compact]", ["dl"]);
|
||||
t( "Attribute Exists", "[controls]", ["video1"]);
|
||||
t( "Attribute Exists", "[declare]", ["object1"]);
|
||||
t( "Attribute Exists", "[defer]", ["script1"]);
|
||||
t( "Attribute Exists", "[disabled]", ["check1"]);
|
||||
t( "Attribute Exists", "[formnovalidate]", ["form1"]);
|
||||
t( "Attribute Exists", "[hidden]", ["div1"]);
|
||||
t( "Attribute Exists", "[indeterminate]", []);
|
||||
t( "Attribute Exists", "[ismap]", ["img1"]);
|
||||
t( "Attribute Exists", "[itemscope]", ["div1"]);
|
||||
t( "Attribute Exists", "[loop]", ["video1"]);
|
||||
t( "Attribute Exists", "[multiple]", ["select1"]);
|
||||
t( "Attribute Exists", "[muted]", ["audio1"]);
|
||||
t( "Attribute Exists", "[nohref]", ["area1"]);
|
||||
t( "Attribute Exists", "[noresize]", ["textarea1"]);
|
||||
t( "Attribute Exists", "[noshade]", ["hr1"]);
|
||||
t( "Attribute Exists", "[nowrap]", ["td1", "div1"]);
|
||||
t( "Attribute Exists", "[novalidate]", ["form1"]);
|
||||
t( "Attribute Exists", "[open]", ["details1"]);
|
||||
t( "Attribute Exists", "[pubdate]", ["article1"]);
|
||||
t( "Attribute Exists", "[readonly]", ["text1"]);
|
||||
t( "Attribute Exists", "[required]", ["text1"]);
|
||||
t( "Attribute Exists", "[reversed]", ["ol1"]);
|
||||
t( "Attribute Exists", "[scoped]", ["style1"]);
|
||||
t( "Attribute Exists", "[seamless]", ["iframe1"]);
|
||||
t( "Attribute Exists", "[selected]", ["option1"]);
|
||||
t( "Attribute Exists", "[truespeed]", ["marquee1"]);
|
||||
|
||||
// Enumerated attributes (these are not boolean content attributes)
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach([ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
|
||||
t( "Enumerated attribute", "[" + val + "]", ["div1"]);
|
||||
});
|
||||
t( "Enumerated attribute", "[spellcheck]", ["span1"]);
|
||||
|
||||
t( "tabindex selector does not retrieve all elements in IE6/7 (#8473)",
|
||||
"form, [tabindex]", [ "form1", "text1" ] );
|
||||
t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", ["form1"] );
|
||||
}
|
||||
);
|
||||
|
||||
// ====== All known boolean attributes, including html5 booleans ======
|
||||
// autobuffer, autofocus, autoplay, async, checked,
|
||||
// compact, controls, declare, defer, disabled,
|
||||
// formnovalidate, hidden, indeterminate (property only),
|
||||
// ismap, itemscope, loop, multiple, muted, nohref, noresize,
|
||||
// noshade, nowrap, novalidate, open, pubdate, readonly, required,
|
||||
// reversed, scoped, seamless, selected, truespeed, visible (skipping visible attribute, which is on a barprop object)
|
||||
|
||||
t( "Attribute Exists", "[autobuffer]", ["video1"]);
|
||||
t( "Attribute Exists", "[autofocus]", ["text1"]);
|
||||
t( "Attribute Exists", "[autoplay]", ["video1"]);
|
||||
t( "Attribute Exists", "[async]", ["script1"]);
|
||||
t( "Attribute Exists", "[checked]", ["check1"]);
|
||||
t( "Attribute Exists", "[compact]", ["dl"]);
|
||||
t( "Attribute Exists", "[controls]", ["video1"]);
|
||||
t( "Attribute Exists", "[declare]", ["object1"]);
|
||||
t( "Attribute Exists", "[defer]", ["script1"]);
|
||||
t( "Attribute Exists", "[disabled]", ["check1"]);
|
||||
t( "Attribute Exists", "[formnovalidate]", ["form1"]);
|
||||
t( "Attribute Exists", "[hidden]", ["div1"]);
|
||||
t( "Attribute Exists", "[indeterminate]", []);
|
||||
t( "Attribute Exists", "[ismap]", ["img1"]);
|
||||
t( "Attribute Exists", "[itemscope]", ["div1"]);
|
||||
t( "Attribute Exists", "[loop]", ["video1"]);
|
||||
t( "Attribute Exists", "[multiple]", ["select1"]);
|
||||
t( "Attribute Exists", "[muted]", ["audio1"]);
|
||||
t( "Attribute Exists", "[nohref]", ["area1"]);
|
||||
t( "Attribute Exists", "[noresize]", ["textarea1"]);
|
||||
t( "Attribute Exists", "[noshade]", ["hr1"]);
|
||||
t( "Attribute Exists", "[nowrap]", ["td1", "div1"]);
|
||||
t( "Attribute Exists", "[novalidate]", ["form1"]);
|
||||
t( "Attribute Exists", "[open]", ["details1"]);
|
||||
t( "Attribute Exists", "[pubdate]", ["article1"]);
|
||||
t( "Attribute Exists", "[readonly]", ["text1"]);
|
||||
t( "Attribute Exists", "[required]", ["text1"]);
|
||||
t( "Attribute Exists", "[reversed]", ["ol1"]);
|
||||
t( "Attribute Exists", "[scoped]", ["style1"]);
|
||||
t( "Attribute Exists", "[seamless]", ["iframe1"]);
|
||||
t( "Attribute Exists", "[selected]", ["option1"]);
|
||||
t( "Attribute Exists", "[truespeed]", ["marquee1"]);
|
||||
|
||||
// Enumerated attributes (these are not boolean content attributes)
|
||||
jQuery.expandedEach = jQuery.each;
|
||||
jQuery.expandedEach([ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
|
||||
t( "Enumerated attribute", "[" + val + "]", ["div1"]);
|
||||
});
|
||||
t( "Enumerated attribute", "[spellcheck]", ["span1"]);
|
||||
|
||||
t( "tabindex selector does not retrieve all elements in IE6/7 (#8473)",
|
||||
"form, [tabindex]", [ "form1", "text1" ] );
|
||||
t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", ["form1"] );
|
||||
});
|
||||
|
||||
test( "jQuery.contains", function() {
|
||||
expect( 16 );
|
||||
QUnit.test( "jQuery.contains", function( assert ) {
|
||||
assert.expect( 16 );
|
||||
|
||||
var container = document.getElementById("nonnodes"),
|
||||
element = container.firstChild,
|
||||
text = element.nextSibling,
|
||||
nonContained = container.nextSibling,
|
||||
detached = document.createElement("a");
|
||||
ok( element && element.nodeType === 1, "preliminary: found element" );
|
||||
ok( text && text.nodeType === 3, "preliminary: found text" );
|
||||
ok( nonContained, "preliminary: found non-descendant" );
|
||||
ok( jQuery.contains(container, element), "child" );
|
||||
ok( jQuery.contains(container.parentNode, element), "grandchild" );
|
||||
ok( jQuery.contains(container, text), "text child" );
|
||||
ok( jQuery.contains(container.parentNode, text), "text grandchild" );
|
||||
ok( !jQuery.contains(container, container), "self" );
|
||||
ok( !jQuery.contains(element, container), "parent" );
|
||||
ok( !jQuery.contains(container, nonContained), "non-descendant" );
|
||||
ok( !jQuery.contains(container, document), "document" );
|
||||
ok( !jQuery.contains(container, document.documentElement), "documentElement (negative)" );
|
||||
ok( !jQuery.contains(container, null), "Passing null does not throw an error" );
|
||||
ok( jQuery.contains(document, document.documentElement), "documentElement (positive)" );
|
||||
ok( jQuery.contains(document, element), "document container (positive)" );
|
||||
ok( !jQuery.contains(document, detached), "document container (negative)" );
|
||||
assert.ok( element && element.nodeType === 1, "preliminary: found element" );
|
||||
assert.ok( text && text.nodeType === 3, "preliminary: found text" );
|
||||
assert.ok( nonContained, "preliminary: found non-descendant" );
|
||||
assert.ok( jQuery.contains(container, element), "child" );
|
||||
assert.ok( jQuery.contains(container.parentNode, element), "grandchild" );
|
||||
assert.ok( jQuery.contains(container, text), "text child" );
|
||||
assert.ok( jQuery.contains(container.parentNode, text), "text grandchild" );
|
||||
assert.ok( !jQuery.contains(container, container), "self" );
|
||||
assert.ok( !jQuery.contains(element, container), "parent" );
|
||||
assert.ok( !jQuery.contains(container, nonContained), "non-descendant" );
|
||||
assert.ok( !jQuery.contains(container, document), "document" );
|
||||
assert.ok( !jQuery.contains(container, document.documentElement), "documentElement (negative)" );
|
||||
assert.ok( !jQuery.contains(container, null), "Passing null does not throw an error" );
|
||||
assert.ok( jQuery.contains(document, document.documentElement), "documentElement (positive)" );
|
||||
assert.ok( jQuery.contains(document, element), "document container (positive)" );
|
||||
assert.ok( !jQuery.contains(document, detached), "document container (negative)" );
|
||||
});
|
||||
|
||||
test("jQuery.uniqueSort", function() {
|
||||
expect( 15 );
|
||||
QUnit.test("jQuery.uniqueSort", function( assert ) {
|
||||
assert.expect( 15 );
|
||||
|
||||
function Arrayish( arr ) {
|
||||
var i = this.length = arr.length;
|
||||
@ -460,24 +464,28 @@ test("jQuery.uniqueSort", function() {
|
||||
|
||||
jQuery.each( tests, function( label, test ) {
|
||||
var length = test.length || test.input.length;
|
||||
deepEqual( jQuery.uniqueSort( test.input ).slice( 0, length ), test.expected, label + " (array)" );
|
||||
deepEqual( jQuery.uniqueSort( new Arrayish(test.input) ).slice( 0, length ), test.expected, label + " (quasi-array)" );
|
||||
assert.deepEqual( jQuery.uniqueSort( test.input ).slice( 0, length ), test.expected, label + " (array)" );
|
||||
assert.deepEqual( jQuery.uniqueSort( new Arrayish(test.input) ).slice( 0, length ), test.expected, label + " (quasi-array)" );
|
||||
});
|
||||
|
||||
strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias for jQuery.uniqueSort()" );
|
||||
assert.strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias for jQuery.uniqueSort()" );
|
||||
});
|
||||
|
||||
testIframe("selector/sizzle_cache", "Sizzle cache collides with multiple Sizzles on a page", function( jQuery, window, document ) {
|
||||
var $cached = window["$cached"];
|
||||
testIframe(
|
||||
"selector/sizzle_cache",
|
||||
"Sizzle cache collides with multiple Sizzles on a page",
|
||||
function( jQuery, window, document, assert ) {
|
||||
var $cached = window["$cached"];
|
||||
|
||||
expect(4);
|
||||
notStrictEqual( jQuery, $cached, "Loaded two engines" );
|
||||
deepEqual( $cached(".test a").get(), [ document.getElementById("collision") ], "Select collision anchor with first sizzle" );
|
||||
equal( jQuery(".evil a").length, 0, "Select nothing with second sizzle" );
|
||||
equal( jQuery(".evil a").length, 0, "Select nothing again with second sizzle" );
|
||||
});
|
||||
assert.expect(4);
|
||||
assert.notStrictEqual( jQuery, $cached, "Loaded two engines" );
|
||||
assert.deepEqual( $cached(".test a").get(), [ document.getElementById("collision") ], "Select collision anchor with first sizzle" );
|
||||
assert.equal( jQuery(".evil a").length, 0, "Select nothing with second sizzle" );
|
||||
assert.equal( jQuery(".evil a").length, 0, "Select nothing again with second sizzle" );
|
||||
}
|
||||
);
|
||||
|
||||
asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, function() {
|
||||
QUnit.asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, function( assert ) {
|
||||
var loaded = false,
|
||||
thrown = false,
|
||||
iframe = document.getElementById( "iframe" ),
|
||||
@ -494,12 +502,12 @@ asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, function() {
|
||||
}
|
||||
|
||||
if ( loaded ) {
|
||||
strictEqual( thrown, false, "No error thrown from post-reload jQuery call" );
|
||||
assert.strictEqual( thrown, false, "No error thrown from post-reload jQuery call" );
|
||||
|
||||
// clean up
|
||||
jQuery( iframe ).off();
|
||||
|
||||
start();
|
||||
QUnit.start();
|
||||
} else {
|
||||
loaded = true;
|
||||
form.submit();
|
||||
|
@ -1,43 +1,43 @@
|
||||
module("serialize", { teardown: moduleTeardown });
|
||||
QUnit.module("serialize", { teardown: moduleTeardown });
|
||||
|
||||
test("jQuery.param()", function() {
|
||||
expect(22);
|
||||
QUnit.test("jQuery.param()", function( assert ) {
|
||||
assert.expect(22);
|
||||
|
||||
var params, settings;
|
||||
|
||||
equal( !( jQuery.ajaxSettings && jQuery.ajaxSettings.traditional ), true, "traditional flag, falsy by default" );
|
||||
assert.equal( !( jQuery.ajaxSettings && jQuery.ajaxSettings.traditional ), true, "traditional flag, falsy by default" );
|
||||
|
||||
params = {"foo":"bar", "baz":42, "quux":"All your base are belong to us"};
|
||||
equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
assert.equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
|
||||
params = {"string":"foo","null":null,"undefined":undefined};
|
||||
equal( jQuery.param(params), "string=foo&null=&undefined=", "handle nulls and undefineds properly" );
|
||||
assert.equal( jQuery.param(params), "string=foo&null=&undefined=", "handle nulls and undefineds properly" );
|
||||
|
||||
params = {"someName": [1, 2, 3], "regularThing": "blah" };
|
||||
equal( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" );
|
||||
assert.equal( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" );
|
||||
|
||||
params = {"foo": ["a", "b", "c"]};
|
||||
equal( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" );
|
||||
assert.equal( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" );
|
||||
|
||||
params = {"foo": ["baz", 42, "All your base are belong to us"] };
|
||||
equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
assert.equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
|
||||
params = {"foo": { "bar": "baz", "beep": 42, "quux": "All your base are belong to us" } };
|
||||
equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
assert.equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
equal( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" );
|
||||
assert.equal( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" );
|
||||
|
||||
params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, "d": 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
|
||||
equal( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" );
|
||||
assert.equal( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" );
|
||||
|
||||
params = { "a":[1,2], "b":{ "c":3, "d":[4,5], "e":{ "x":[6], "y":7, "z":[8,9] }, "f":true, "g":false, "h":undefined }, "i":[10,11], "j":true, "k":false, "l":[undefined,0], "m":"cowboy hat?" };
|
||||
equal( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
|
||||
assert.equal( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
|
||||
|
||||
equal( decodeURIComponent( jQuery.param({ "a": [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], "e": { "f": [10], "g": [11,12], "h": 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
assert.equal( decodeURIComponent( jQuery.param({ "a": [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], "e": { "f": [10], "g": [11,12], "h": 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
|
||||
|
||||
// #7945
|
||||
equal( jQuery.param({"jquery": "1.4.2"}), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" );
|
||||
assert.equal( jQuery.param({"jquery": "1.4.2"}), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" );
|
||||
|
||||
settings = { traditional: true };
|
||||
|
||||
@ -48,34 +48,34 @@ test("jQuery.param()", function() {
|
||||
}
|
||||
|
||||
params = {"foo":"bar", "baz":42, "quux":"All your base are belong to us"};
|
||||
equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
assert.equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
|
||||
|
||||
params = {"someName": [1, 2, 3], "regularThing": "blah" };
|
||||
equal( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
|
||||
assert.equal( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
|
||||
|
||||
params = {"foo": ["a", "b", "c"]};
|
||||
equal( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" );
|
||||
assert.equal( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" );
|
||||
|
||||
params = {"foo[]":["baz", 42, "All your base are belong to us"]};
|
||||
equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
assert.equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
|
||||
|
||||
params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"};
|
||||
equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
assert.equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
equal( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" );
|
||||
assert.equal( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" );
|
||||
|
||||
params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
|
||||
equal( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" );
|
||||
assert.equal( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" );
|
||||
|
||||
params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
|
||||
equal( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" );
|
||||
assert.equal( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" );
|
||||
|
||||
params = { "param1": null };
|
||||
equal( jQuery.param(params,false), "param1=", "Make sure that null params aren't traversed." );
|
||||
assert.equal( jQuery.param(params,false), "param1=", "Make sure that null params aren't traversed." );
|
||||
|
||||
params = {"test": {"length": 3, "foo": "bar"} };
|
||||
equal( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" );
|
||||
assert.equal( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" );
|
||||
|
||||
if ( jQuery.ajaxSettings === settings ) {
|
||||
delete jQuery.ajaxSettings;
|
||||
@ -84,8 +84,8 @@ test("jQuery.param()", function() {
|
||||
}
|
||||
});
|
||||
|
||||
test("jQuery.param() Constructed prop values", function() {
|
||||
expect( 4 );
|
||||
QUnit.test("jQuery.param() Constructed prop values", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
/** @constructor */
|
||||
function Record() {
|
||||
@ -96,21 +96,21 @@ test("jQuery.param() Constructed prop values", function() {
|
||||
MyNumber = Number,
|
||||
params = { "test": new MyString("foo") };
|
||||
|
||||
equal( jQuery.param( params, false ), "test=foo", "Do not mistake new String() for a plain object" );
|
||||
assert.equal( jQuery.param( params, false ), "test=foo", "Do not mistake new String() for a plain object" );
|
||||
|
||||
params = { "test": new MyNumber(5) };
|
||||
equal( jQuery.param( params, false ), "test=5", "Do not mistake new Number() for a plain object" );
|
||||
assert.equal( jQuery.param( params, false ), "test=5", "Do not mistake new Number() for a plain object" );
|
||||
|
||||
params = { "test": new Date() };
|
||||
ok( jQuery.param( params, false ), "(Non empty string returned) Do not mistake new Date() for a plain object" );
|
||||
assert.ok( jQuery.param( params, false ), "(Non empty string returned) Do not mistake new Date() for a plain object" );
|
||||
|
||||
// should allow non-native constructed objects
|
||||
params = { "test": new Record() };
|
||||
equal( jQuery.param( params, false ), jQuery.param({ "test": { "prop": "val" } }), "Allow non-native constructed objects" );
|
||||
assert.equal( jQuery.param( params, false ), jQuery.param({ "test": { "prop": "val" } }), "Allow non-native constructed objects" );
|
||||
});
|
||||
|
||||
test("serialize()", function() {
|
||||
expect(6);
|
||||
QUnit.test("serialize()", function( assert ) {
|
||||
assert.expect(6);
|
||||
|
||||
// Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers
|
||||
jQuery("#search").after(
|
||||
@ -119,27 +119,27 @@ test("serialize()", function() {
|
||||
"<input type='file' name='fileupload' />"
|
||||
);
|
||||
|
||||
equal( jQuery("#form").serialize(),
|
||||
assert.equal( jQuery("#form").serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
|
||||
"Check form serialization as query string");
|
||||
|
||||
equal( jQuery("input,select,textarea,button", "#form").serialize(),
|
||||
assert.equal( jQuery("input,select,textarea,button", "#form").serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
|
||||
"Check input serialization as query string");
|
||||
|
||||
equal( jQuery("#testForm").serialize(),
|
||||
assert.equal( jQuery("#testForm").serialize(),
|
||||
"T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Check form serialization as query string");
|
||||
|
||||
equal( jQuery("input,select,textarea,button", "#testForm").serialize(),
|
||||
assert.equal( jQuery("input,select,textarea,button", "#testForm").serialize(),
|
||||
"T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Check input serialization as query string");
|
||||
|
||||
equal( jQuery("#form, #testForm").serialize(),
|
||||
assert.equal( jQuery("#form, #testForm").serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Multiple form serialization as query string");
|
||||
|
||||
equal( jQuery("#form, #testForm :input").serialize(),
|
||||
assert.equal( jQuery("#form, #testForm :input").serialize(),
|
||||
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
|
||||
"Mixed form/input serialization as query string");
|
||||
jQuery("#html5email, #html5number").remove();
|
||||
|
@ -1,4 +1,4 @@
|
||||
module("support", { teardown: moduleTeardown });
|
||||
QUnit.module("support", { teardown: moduleTeardown });
|
||||
|
||||
var computedSupport = getComputedSupport( jQuery.support );
|
||||
|
||||
@ -18,30 +18,35 @@ function getComputedSupport( support ) {
|
||||
}
|
||||
|
||||
if ( jQuery.css ) {
|
||||
testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9239)", "support/bodyBackground.html", function( color, support ) {
|
||||
expect( 2 );
|
||||
var okValue = {
|
||||
"#000000": true,
|
||||
"rgb(0, 0, 0)": true
|
||||
};
|
||||
ok( okValue[ color ], "color was not reset (" + color + ")" );
|
||||
testIframeWithCallback(
|
||||
"body background is not lost if set prior to loading jQuery (#9239)",
|
||||
"support/bodyBackground.html",
|
||||
function( color, support, assert ) {
|
||||
assert.expect( 2 );
|
||||
var okValue = {
|
||||
"#000000": true,
|
||||
"rgb(0, 0, 0)": true
|
||||
};
|
||||
assert.ok( okValue[ color ], "color was not reset (" + color + ")" );
|
||||
|
||||
deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
|
||||
});
|
||||
assert.deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// This test checks CSP only for browsers with "Content-Security-Policy" header support
|
||||
// i.e. no old WebKit or old Firefox
|
||||
testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
|
||||
testIframeWithCallback(
|
||||
"Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
|
||||
"support/csp.php",
|
||||
function( support ) {
|
||||
expect( 2 );
|
||||
deepEqual( jQuery.extend( {}, support ), computedSupport, "No violations of CSP polices" );
|
||||
function( support, assert ) {
|
||||
assert.expect( 2 );
|
||||
assert.deepEqual( jQuery.extend( {}, support ), computedSupport, "No violations of CSP polices" );
|
||||
|
||||
stop();
|
||||
QUnit.stop();
|
||||
|
||||
supportjQuery.get( "data/support/csp.log" ).done(function( data ) {
|
||||
equal( data, "", "No log request should be sent" );
|
||||
assert.equal( data, "", "No log request should be sent" );
|
||||
supportjQuery.get( "data/support/csp-clean.php" ).done( start );
|
||||
});
|
||||
}
|
||||
@ -254,7 +259,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
|
||||
}
|
||||
|
||||
if ( expected ) {
|
||||
test( "Verify that the support tests resolve as expected per browser", function() {
|
||||
QUnit.test( "Verify that the support tests resolve as expected per browser", function( assert ) {
|
||||
var i, prop,
|
||||
j = 0;
|
||||
|
||||
@ -262,16 +267,16 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
|
||||
j++;
|
||||
}
|
||||
|
||||
expect( j );
|
||||
assert.expect( j );
|
||||
|
||||
for ( i in expected ) {
|
||||
// TODO check for all modules containing support properties
|
||||
if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
|
||||
equal( computedSupport[ i ], expected[ i ],
|
||||
assert.equal( computedSupport[ i ], expected[ i ],
|
||||
"jQuery.support['" + i + "']: " + computedSupport[ i ] +
|
||||
", expected['" + i + "']: " + expected[ i ]);
|
||||
} else {
|
||||
ok( true, "no ajax; skipping jQuery.support[' " + i + " ']" );
|
||||
assert.ok( true, "no ajax; skipping jQuery.support[' " + i + " ']" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ if ( !jQuery.fx ) {
|
||||
|
||||
var oldRaf = window.requestAnimationFrame;
|
||||
|
||||
module( "tween", {
|
||||
QUnit.module( "tween", {
|
||||
setup: function() {
|
||||
window.requestAnimationFrame = null;
|
||||
this.sandbox = sinon.sandbox.create();
|
||||
@ -27,79 +27,79 @@ module( "tween", {
|
||||
}
|
||||
} );
|
||||
|
||||
test( "jQuery.Tween - Default propHooks on plain objects", function() {
|
||||
expect( 8 );
|
||||
QUnit.test( "jQuery.Tween - Default propHooks on plain objects", function( assert ) {
|
||||
assert.expect( 8 );
|
||||
var propHooks, defaultHook, testObject, fakeTween, stepSpy;
|
||||
|
||||
propHooks = jQuery.Tween.propHooks;
|
||||
equal( typeof propHooks, "object", "jQuery.Tween.propHooks exists" );
|
||||
assert.equal( typeof propHooks, "object", "jQuery.Tween.propHooks exists" );
|
||||
|
||||
defaultHook = propHooks._default;
|
||||
ok( defaultHook, "_default propHook exists" );
|
||||
assert.ok( defaultHook, "_default propHook exists" );
|
||||
|
||||
testObject = { test: 0 };
|
||||
fakeTween = { elem: testObject, prop: "test", now: 10, unit: "px" };
|
||||
|
||||
equal( defaultHook.get( fakeTween ), 0, "Can get property of object" );
|
||||
assert.equal( defaultHook.get( fakeTween ), 0, "Can get property of object" );
|
||||
|
||||
fakeTween.prop = "testMissing";
|
||||
equal( defaultHook.get( fakeTween ), undefined, "Can get missing property on object" );
|
||||
assert.equal( defaultHook.get( fakeTween ), undefined, "Can get missing property on object" );
|
||||
|
||||
defaultHook.set( fakeTween );
|
||||
equal( testObject.testMissing, 10, "Sets missing value properly on plain object" );
|
||||
assert.equal( testObject.testMissing, 10, "Sets missing value properly on plain object" );
|
||||
|
||||
fakeTween.prop = "opacity";
|
||||
defaultHook.set( fakeTween );
|
||||
equal( testObject.opacity, 10, "Correctly set opacity on plain object" );
|
||||
assert.equal( testObject.opacity, 10, "Correctly set opacity on plain object" );
|
||||
|
||||
fakeTween.prop = "test";
|
||||
stepSpy = jQuery.fx.step.test = this.sandbox.spy();
|
||||
|
||||
defaultHook.set( fakeTween );
|
||||
ok( stepSpy.calledWith( fakeTween ), "Step function called with Tween" );
|
||||
equal( testObject.test, 0, "Because step didn't set, value is unchanged" );
|
||||
assert.ok( stepSpy.calledWith( fakeTween ), "Step function called with Tween" );
|
||||
assert.equal( testObject.test, 0, "Because step didn't set, value is unchanged" );
|
||||
} );
|
||||
|
||||
test( "jQuery.Tween - Default propHooks on elements", function() {
|
||||
expect( 19 );
|
||||
QUnit.test( "jQuery.Tween - Default propHooks on elements", function( assert ) {
|
||||
assert.expect( 19 );
|
||||
var propHooks, defaultHook, testElement, fakeTween, cssStub, styleStub, stepSpy;
|
||||
|
||||
propHooks = jQuery.Tween.propHooks;
|
||||
equal( typeof propHooks, "object", "jQuery.Tween.propHooks exists" );
|
||||
assert.equal( typeof propHooks, "object", "jQuery.Tween.propHooks exists" );
|
||||
|
||||
defaultHook = propHooks._default;
|
||||
ok( defaultHook, "_default propHook exists" );
|
||||
assert.ok( defaultHook, "_default propHook exists" );
|
||||
|
||||
testElement = jQuery( "<div>" )[ 0 ];
|
||||
fakeTween = { elem: testElement, prop: "height", now: 10, unit: "px" };
|
||||
|
||||
cssStub = this.sandbox.stub( jQuery, "css" ).returns( 10 );
|
||||
|
||||
equal( defaultHook.get( fakeTween ), 10, "Gets expected style value" );
|
||||
ok( cssStub.calledWith( testElement, "height", "" ), "Calls jQuery.css correctly" );
|
||||
assert.equal( defaultHook.get( fakeTween ), 10, "Gets expected style value" );
|
||||
assert.ok( cssStub.calledWith( testElement, "height", "" ), "Calls jQuery.css correctly" );
|
||||
|
||||
fakeTween.prop = "testOpti";
|
||||
testElement.testOpti = 15;
|
||||
cssStub.reset();
|
||||
|
||||
equal( defaultHook.get( fakeTween ), 15, "Gets expected value not defined on style" );
|
||||
equal( cssStub.callCount, 0, "Did not call jQuery.css" );
|
||||
assert.equal( defaultHook.get( fakeTween ), 15, "Gets expected value not defined on style" );
|
||||
assert.equal( cssStub.callCount, 0, "Did not call jQuery.css" );
|
||||
|
||||
fakeTween.prop = "testMissing";
|
||||
equal( defaultHook.get( fakeTween ), 10, "Can get missing property on element" );
|
||||
ok( cssStub.calledWith( testElement, "testMissing", "" ), "...using jQuery.css" );
|
||||
assert.equal( defaultHook.get( fakeTween ), 10, "Can get missing property on element" );
|
||||
assert.ok( cssStub.calledWith( testElement, "testMissing", "" ), "...using jQuery.css" );
|
||||
|
||||
cssStub.returns( "" );
|
||||
equal( defaultHook.get( fakeTween ), 0, "Uses 0 for empty string" );
|
||||
assert.equal( defaultHook.get( fakeTween ), 0, "Uses 0 for empty string" );
|
||||
|
||||
cssStub.returns( "auto" );
|
||||
equal( defaultHook.get( fakeTween ), 0, "Uses 0 for 'auto'" );
|
||||
assert.equal( defaultHook.get( fakeTween ), 0, "Uses 0 for 'auto'" );
|
||||
|
||||
cssStub.returns( null );
|
||||
equal( defaultHook.get( fakeTween ), 0, "Uses 0 for null" );
|
||||
assert.equal( defaultHook.get( fakeTween ), 0, "Uses 0 for null" );
|
||||
|
||||
cssStub.returns( undefined );
|
||||
equal( defaultHook.get( fakeTween ), 0, "Uses 0 for undefined" );
|
||||
assert.equal( defaultHook.get( fakeTween ), 0, "Uses 0 for undefined" );
|
||||
|
||||
cssStub.reset();
|
||||
|
||||
@ -108,15 +108,15 @@ test( "jQuery.Tween - Default propHooks on elements", function() {
|
||||
fakeTween.prop = "height";
|
||||
|
||||
defaultHook.set( fakeTween );
|
||||
ok( styleStub.calledWith( testElement, "height", "10px" ),
|
||||
assert.ok( styleStub.calledWith( testElement, "height", "10px" ),
|
||||
"Calls jQuery.style with elem, prop, now+unit" );
|
||||
|
||||
styleStub.reset();
|
||||
fakeTween.prop = "testMissing";
|
||||
|
||||
defaultHook.set( fakeTween );
|
||||
equal( styleStub.callCount, 0, "Did not call jQuery.style for non css property" );
|
||||
equal( testElement.testMissing, 10, "Instead, set value on element directly" );
|
||||
assert.equal( styleStub.callCount, 0, "Did not call jQuery.style for non css property" );
|
||||
assert.equal( testElement.testMissing, 10, "Instead, set value on element directly" );
|
||||
|
||||
jQuery.cssHooks.testMissing = jQuery.noop;
|
||||
fakeTween.now = 11;
|
||||
@ -124,91 +124,100 @@ test( "jQuery.Tween - Default propHooks on elements", function() {
|
||||
defaultHook.set( fakeTween );
|
||||
delete jQuery.cssHooks.testMissing;
|
||||
|
||||
ok( styleStub.calledWith( testElement, "testMissing", "11px" ),
|
||||
assert.ok( styleStub.calledWith( testElement, "testMissing", "11px" ),
|
||||
"Presence of cssHooks causes jQuery.style with elem, prop, now+unit" );
|
||||
equal( testElement.testMissing, 10, "And value was unchanged" );
|
||||
assert.equal( testElement.testMissing, 10, "And value was unchanged" );
|
||||
|
||||
stepSpy = jQuery.fx.step.test = this.sandbox.spy();
|
||||
styleStub.reset();
|
||||
|
||||
fakeTween.prop = "test";
|
||||
defaultHook.set( fakeTween );
|
||||
ok( stepSpy.calledWith( fakeTween ), "Step function called with Tween" );
|
||||
equal( styleStub.callCount, 0, "Did not call jQuery.style" );
|
||||
assert.ok( stepSpy.calledWith( fakeTween ), "Step function called with Tween" );
|
||||
assert.equal( styleStub.callCount, 0, "Did not call jQuery.style" );
|
||||
} );
|
||||
|
||||
test( "jQuery.Tween - Plain Object", function() {
|
||||
expect( 13 );
|
||||
QUnit.test( "jQuery.Tween - Plain Object", function( assert ) {
|
||||
assert.expect( 13 );
|
||||
var testObject = { test: 100 },
|
||||
testOptions = { duration: 100 },
|
||||
tween, easingSpy;
|
||||
|
||||
tween = jQuery.Tween( testObject, testOptions, "test", 0, "linear" );
|
||||
equal( tween.elem, testObject, "Sets .element" );
|
||||
equal( tween.options, testOptions, "sets .options" );
|
||||
equal( tween.prop, "test", "sets .prop" );
|
||||
equal( tween.end, 0, "sets .end" );
|
||||
assert.equal( tween.elem, testObject, "Sets .element" );
|
||||
assert.equal( tween.options, testOptions, "sets .options" );
|
||||
assert.equal( tween.prop, "test", "sets .prop" );
|
||||
assert.equal( tween.end, 0, "sets .end" );
|
||||
|
||||
equal( tween.easing, "linear", "sets .easing when provided" );
|
||||
assert.equal( tween.easing, "linear", "sets .easing when provided" );
|
||||
|
||||
equal( tween.start, 100, "Reads .start value during construction" );
|
||||
equal( tween.now, 100, "Reads .now value during construction" );
|
||||
assert.equal( tween.start, 100, "Reads .start value during construction" );
|
||||
assert.equal( tween.now, 100, "Reads .now value during construction" );
|
||||
|
||||
easingSpy = this.sandbox.spy( jQuery.easing, "linear" );
|
||||
|
||||
equal( tween.run( 0.1 ), tween, ".run() returns this" );
|
||||
assert.equal( tween.run( 0.1 ), tween, ".run() returns this" );
|
||||
|
||||
equal( tween.now, 90, "Calculated tween" );
|
||||
assert.equal( tween.now, 90, "Calculated tween" );
|
||||
|
||||
ok( easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ),
|
||||
assert.ok( easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ),
|
||||
"...using jQuery.easing.linear with back-compat arguments" );
|
||||
equal( testObject.test, 90, "Set value" );
|
||||
assert.equal( testObject.test, 90, "Set value" );
|
||||
|
||||
tween.run( 1 );
|
||||
equal( testObject.test, 0, "Checking another value" );
|
||||
assert.equal( testObject.test, 0, "Checking another value" );
|
||||
|
||||
tween.run( 0 );
|
||||
equal( testObject.test, 100, "Can even go back in time" );
|
||||
assert.equal( testObject.test, 100, "Can even go back in time" );
|
||||
} );
|
||||
|
||||
test( "jQuery.Tween - Element", function() {
|
||||
expect( 15 );
|
||||
QUnit.test( "jQuery.Tween - Element", function( assert ) {
|
||||
assert.expect( 15 );
|
||||
var testElement = jQuery( "<div>" ).css( "height", 100 )[ 0 ],
|
||||
testOptions = { duration: 100 },
|
||||
tween, easingSpy, eased;
|
||||
|
||||
tween = jQuery.Tween( testElement, testOptions, "height", 0 );
|
||||
equal( tween.elem, testElement, "Sets .element" );
|
||||
equal( tween.options, testOptions, "sets .options" );
|
||||
equal( tween.prop, "height", "sets .prop" );
|
||||
equal( tween.end, 0, "sets .end" );
|
||||
assert.equal( tween.elem, testElement, "Sets .element" );
|
||||
assert.equal( tween.options, testOptions, "sets .options" );
|
||||
assert.equal( tween.prop, "height", "sets .prop" );
|
||||
assert.equal( tween.end, 0, "sets .end" );
|
||||
|
||||
equal( tween.easing, jQuery.easing._default, "sets .easing to default when not provided" );
|
||||
equal( tween.unit, "px", "sets .unit to px when not provided" );
|
||||
assert.equal(
|
||||
tween.easing,
|
||||
jQuery.easing._default,
|
||||
"sets .easing to default when not provided"
|
||||
);
|
||||
assert.equal( tween.unit, "px", "sets .unit to px when not provided" );
|
||||
|
||||
equal( tween.start, 100, "Reads .start value during construction" );
|
||||
equal( tween.now, 100, "Reads .now value during construction" );
|
||||
assert.equal( tween.start, 100, "Reads .start value during construction" );
|
||||
assert.equal( tween.now, 100, "Reads .now value during construction" );
|
||||
|
||||
easingSpy = this.sandbox.spy( jQuery.easing, "swing" );
|
||||
|
||||
equal( tween.run( 0.1 ), tween, ".run() returns this" );
|
||||
equal( tween.pos, jQuery.easing.swing( 0.1 ), "set .pos" );
|
||||
assert.equal( tween.run( 0.1 ), tween, ".run() returns this" );
|
||||
assert.equal( tween.pos, jQuery.easing.swing( 0.1 ), "set .pos" );
|
||||
eased = 100 - ( jQuery.easing.swing( 0.1 ) * 100 );
|
||||
equal( tween.now, eased, "Calculated tween" );
|
||||
assert.equal( tween.now, eased, "Calculated tween" );
|
||||
|
||||
ok( easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ),
|
||||
"...using jQuery.easing.linear with back-compat arguments" );
|
||||
equal( parseFloat( testElement.style.height ).toFixed( 2 ), eased.toFixed( 2 ), "Set value" );
|
||||
assert.ok(
|
||||
easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ),
|
||||
"...using jQuery.easing.linear with back-compat arguments"
|
||||
);
|
||||
assert.equal(
|
||||
parseFloat( testElement.style.height ).toFixed( 2 ),
|
||||
eased.toFixed( 2 ), "Set value"
|
||||
);
|
||||
|
||||
tween.run( 1 );
|
||||
equal( testElement.style.height, "0px", "Checking another value" );
|
||||
assert.equal( testElement.style.height, "0px", "Checking another value" );
|
||||
|
||||
tween.run( 0 );
|
||||
equal( testElement.style.height, "100px", "Can even go back in time" );
|
||||
assert.equal( testElement.style.height, "100px", "Can even go back in time" );
|
||||
} );
|
||||
|
||||
test( "jQuery.Tween - No duration", function() {
|
||||
expect( 3 );
|
||||
QUnit.test( "jQuery.Tween - No duration", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var testObject = { test: 100 },
|
||||
testOptions = { duration: 0 },
|
||||
@ -218,13 +227,13 @@ test( "jQuery.Tween - No duration", function() {
|
||||
easingSpy = this.sandbox.spy( jQuery.easing, "swing" );
|
||||
tween.run( 0.5 );
|
||||
|
||||
equal( tween.pos, 0.5, "set .pos correctly" );
|
||||
equal( testObject.test, 50, "set value on object correctly" );
|
||||
equal( easingSpy.callCount, 0, "didn't ease the value" );
|
||||
assert.equal( tween.pos, 0.5, "set .pos correctly" );
|
||||
assert.equal( testObject.test, 50, "set value on object correctly" );
|
||||
assert.equal( easingSpy.callCount, 0, "didn't ease the value" );
|
||||
} );
|
||||
|
||||
test( "jQuery.Tween - step function option", function() {
|
||||
expect( 4 );
|
||||
QUnit.test( "jQuery.Tween - step function option", function( assert ) {
|
||||
assert.expect( 4 );
|
||||
|
||||
var testObject = { test: 100 },
|
||||
testOptions = { duration: 100, step: this.sandbox.spy() },
|
||||
@ -233,20 +242,26 @@ test( "jQuery.Tween - step function option", function() {
|
||||
propHookSpy = this.sandbox.spy( jQuery.Tween.propHooks._default, "set" );
|
||||
|
||||
tween = jQuery.Tween( testObject, testOptions, "test", 0, "linear" );
|
||||
equal( testOptions.step.callCount, 0, "didn't call step on create" );
|
||||
assert.equal( testOptions.step.callCount, 0, "didn't call step on create" );
|
||||
|
||||
tween.run( 0.5 );
|
||||
ok( testOptions.step.calledOn( testObject ),
|
||||
"Called step function in context of animated object" );
|
||||
ok( testOptions.step.calledWith( 50, tween ), "Called step function with correct parameters" );
|
||||
|
||||
ok( testOptions.step.calledBefore( propHookSpy ),
|
||||
"Called step function before calling propHook.set" );
|
||||
assert.ok(
|
||||
testOptions.step.calledOn( testObject ),
|
||||
"Called step function in context of animated object"
|
||||
);
|
||||
assert.ok(
|
||||
testOptions.step.calledWith( 50, tween ),
|
||||
"Called step function with correct parameters"
|
||||
);
|
||||
assert.ok(
|
||||
testOptions.step.calledBefore( propHookSpy ),
|
||||
"Called step function before calling propHook.set"
|
||||
);
|
||||
|
||||
} );
|
||||
|
||||
test( "jQuery.Tween - custom propHooks", function() {
|
||||
expect( 3 );
|
||||
QUnit.test( "jQuery.Tween - custom propHooks", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var testObject = {},
|
||||
testOptions = { duration: 100, step: this.sandbox.spy() },
|
||||
@ -259,17 +274,20 @@ test( "jQuery.Tween - custom propHooks", function() {
|
||||
jQuery.Tween.propHooks.testHooked = propHook;
|
||||
|
||||
tween = jQuery.Tween( testObject, testOptions, "testHooked", 0, "linear" );
|
||||
ok( propHook.get.calledWith( tween ), "called propHook.get on create" );
|
||||
equal( tween.now, 100, "Used return value from propHook.get" );
|
||||
assert.ok( propHook.get.calledWith( tween ), "called propHook.get on create" );
|
||||
assert.equal( tween.now, 100, "Used return value from propHook.get" );
|
||||
|
||||
tween.run( 0.5 );
|
||||
ok( propHook.set.calledWith( tween ), "Called propHook.set function with correct parameters" );
|
||||
assert.ok(
|
||||
propHook.set.calledWith( tween ),
|
||||
"Called propHook.set function with correct parameters"
|
||||
);
|
||||
|
||||
delete jQuery.Tween.propHooks.testHooked;
|
||||
} );
|
||||
|
||||
test( "jQuery.Tween - custom propHooks - advanced values", function() {
|
||||
expect( 5 );
|
||||
QUnit.test( "jQuery.Tween - custom propHooks - advanced values", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var testObject = {},
|
||||
testOptions = { duration: 100, step: this.sandbox.spy() },
|
||||
@ -282,15 +300,18 @@ test( "jQuery.Tween - custom propHooks - advanced values", function() {
|
||||
jQuery.Tween.propHooks.testHooked = propHook;
|
||||
|
||||
tween = jQuery.Tween( testObject, testOptions, "testHooked", [ 1, 1 ], "linear" );
|
||||
ok( propHook.get.calledWith( tween ), "called propHook.get on create" );
|
||||
deepEqual( tween.start, [ 0, 0 ], "Used return value from get" );
|
||||
assert.ok( propHook.get.calledWith( tween ), "called propHook.get on create" );
|
||||
assert.deepEqual( tween.start, [ 0, 0 ], "Used return value from get" );
|
||||
|
||||
tween.run( 0.5 );
|
||||
|
||||
// Some day this NaN assumption might change - perhaps add a "calc" helper to the hooks?
|
||||
ok( isNaN( tween.now ), "Used return value from propHook.get" );
|
||||
equal( tween.pos, 0.5, "But the eased percent is still available" );
|
||||
ok( propHook.set.calledWith( tween ), "Called propHook.set function with correct parameters" );
|
||||
assert.ok( isNaN( tween.now ), "Used return value from propHook.get" );
|
||||
assert.equal( tween.pos, 0.5, "But the eased percent is still available" );
|
||||
assert.ok(
|
||||
propHook.set.calledWith( tween ),
|
||||
"Called propHook.set function with correct parameters"
|
||||
);
|
||||
|
||||
delete jQuery.Tween.propHooks.testHooked;
|
||||
} );
|
||||
|
@ -4,7 +4,7 @@ if ( !jQuery.fn.wrap ) { // no wrap module
|
||||
return;
|
||||
}
|
||||
|
||||
module( "wrap", {
|
||||
QUnit.module( "wrap", {
|
||||
teardown: moduleTeardown
|
||||
});
|
||||
|
||||
@ -19,36 +19,36 @@ function manipulationFunctionReturningObj( value ) {
|
||||
};
|
||||
}
|
||||
|
||||
function testWrap( val ) {
|
||||
function testWrap( val , assert ) {
|
||||
|
||||
expect( 19 );
|
||||
assert.expect( 19 );
|
||||
|
||||
var defaultText, result, j, i, cacheLength;
|
||||
|
||||
defaultText = "Try them out:";
|
||||
result = jQuery("#first").wrap( val("<div class='red'><span></span></div>") ).text();
|
||||
|
||||
equal( defaultText, result, "Check for wrapping of on-the-fly html" );
|
||||
ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
assert.equal( defaultText, result, "Check for wrapping of on-the-fly html" );
|
||||
assert.ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
|
||||
result = jQuery("#first").wrap( val(document.getElementById("empty")) ).parent();
|
||||
ok( result.is("ol"), "Check for element wrapping" );
|
||||
equal( result.text(), defaultText, "Check for element wrapping" );
|
||||
assert.ok( result.is("ol"), "Check for element wrapping" );
|
||||
assert.equal( result.text(), defaultText, "Check for element wrapping" );
|
||||
|
||||
jQuery("#check1").on( "click", function() {
|
||||
var checkbox = this;
|
||||
|
||||
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
||||
assert.ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
||||
jQuery( checkbox ).wrap( val("<div id='c1' style='display:none;'></div>") );
|
||||
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
||||
assert.ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
|
||||
}).prop( "checked", false )[ 0 ].click();
|
||||
|
||||
// using contents will get comments regular, text, and comment nodes
|
||||
j = jQuery("#nonnodes").contents();
|
||||
j.wrap( val("<i></i>") );
|
||||
|
||||
equal( jQuery("#nonnodes > i").length, jQuery("#nonnodes")[ 0 ].childNodes.length, "Check node,textnode,comment wraps ok" );
|
||||
equal( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );
|
||||
assert.equal( jQuery("#nonnodes > i").length, jQuery("#nonnodes")[ 0 ].childNodes.length, "Check node,textnode,comment wraps ok" );
|
||||
assert.equal( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );
|
||||
|
||||
// Try wrapping a disconnected node
|
||||
cacheLength = 0;
|
||||
@ -57,32 +57,32 @@ function testWrap( val ) {
|
||||
}
|
||||
|
||||
j = jQuery("<label/>").wrap( val("<li/>") );
|
||||
equal( j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label" );
|
||||
equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
|
||||
assert.equal( j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label" );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
|
||||
|
||||
for ( i in jQuery.cache ) {
|
||||
cacheLength--;
|
||||
}
|
||||
equal( cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)" );
|
||||
assert.equal( cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)" );
|
||||
|
||||
// Wrap an element containing a text node
|
||||
j = jQuery("<span/>").wrap("<div>test</div>");
|
||||
equal( j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
|
||||
equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." );
|
||||
assert.equal( j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." );
|
||||
|
||||
// Try to wrap an element with multiple elements (should fail)
|
||||
j = jQuery("<div><span></span></div>").children().wrap("<p></p><div></div>");
|
||||
equal( j[ 0 ].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
|
||||
equal( j.length, 1, "There should only be one element (no cloning)." );
|
||||
equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );
|
||||
assert.equal( j[ 0 ].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
|
||||
assert.equal( j.length, 1, "There should only be one element (no cloning)." );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );
|
||||
|
||||
// Wrap an element with a jQuery set
|
||||
j = jQuery("<span/>").wrap( jQuery("<div></div>") );
|
||||
equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
||||
|
||||
// Wrap an element with a jQuery set and event
|
||||
result = jQuery("<div></div>").on( "click", function() {
|
||||
ok( true, "Event triggered." );
|
||||
assert.ok( true, "Event triggered." );
|
||||
|
||||
// Remove handlers on detached elements
|
||||
result.off();
|
||||
@ -90,49 +90,49 @@ function testWrap( val ) {
|
||||
});
|
||||
|
||||
j = jQuery("<span/>").wrap( result );
|
||||
equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
||||
assert.equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." );
|
||||
|
||||
j.parent().trigger("click");
|
||||
}
|
||||
|
||||
test( "wrap(String|Element)", function() {
|
||||
testWrap( manipulationBareObj );
|
||||
QUnit.test( "wrap(String|Element)", function( assert ) {
|
||||
testWrap( manipulationBareObj, assert );
|
||||
});
|
||||
|
||||
test( "wrap(Function)", function() {
|
||||
testWrap( manipulationFunctionReturningObj );
|
||||
QUnit.test( "wrap(Function)", function( assert ) {
|
||||
testWrap( manipulationFunctionReturningObj, assert );
|
||||
});
|
||||
|
||||
test( "wrap(Function) with index (#10177)", function() {
|
||||
QUnit.test( "wrap(Function) with index (#10177)", function( assert ) {
|
||||
var expectedIndex = 0,
|
||||
targets = jQuery("#qunit-fixture p");
|
||||
|
||||
expect( targets.length );
|
||||
assert.expect( targets.length );
|
||||
targets.wrap(function(i) {
|
||||
equal( i, expectedIndex, "Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")" );
|
||||
assert.equal( i, expectedIndex, "Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")" );
|
||||
expectedIndex++;
|
||||
|
||||
return "<div id='wrap_index_'" + i + "'></div>";
|
||||
});
|
||||
});
|
||||
|
||||
test( "wrap(String) consecutive elements (#10177)", function() {
|
||||
QUnit.test( "wrap(String) consecutive elements (#10177)", function( assert ) {
|
||||
var targets = jQuery("#qunit-fixture p");
|
||||
|
||||
expect( targets.length * 2 );
|
||||
assert.expect( targets.length * 2 );
|
||||
targets.wrap("<div class='wrapper'></div>");
|
||||
|
||||
targets.each(function() {
|
||||
var $this = jQuery(this);
|
||||
|
||||
ok( $this.parent().is(".wrapper"), "Check each elements parent is correct (.wrapper)" );
|
||||
equal( $this.siblings().length, 0, "Each element should be wrapped individually" );
|
||||
assert.ok( $this.parent().is(".wrapper"), "Check each elements parent is correct (.wrapper)" );
|
||||
assert.equal( $this.siblings().length, 0, "Each element should be wrapped individually" );
|
||||
});
|
||||
});
|
||||
|
||||
test( "wrapAll(String)", function() {
|
||||
QUnit.test( "wrapAll(String)", function( assert ) {
|
||||
|
||||
expect( 5 );
|
||||
assert.expect( 5 );
|
||||
|
||||
var prev, p, result;
|
||||
|
||||
@ -140,16 +140,16 @@ test( "wrapAll(String)", function() {
|
||||
p = jQuery("#firstp,#first")[ 0 ].parentNode;
|
||||
result = jQuery("#firstp,#first").wrapAll( "<div class='red'><div class='tmp'></div></div>" );
|
||||
|
||||
equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery("#firstp").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
equal( jQuery("#first").parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
equal( jQuery("#first").parent().parent()[ 0 ].parentNode, p, "Correct Parent" );
|
||||
assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
assert.ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
assert.ok( jQuery("#firstp").parent().parent().is(".red"), "Check if wrapper has class 'red'" );
|
||||
assert.equal( jQuery("#first").parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
assert.equal( jQuery("#first").parent().parent()[ 0 ].parentNode, p, "Correct Parent" );
|
||||
|
||||
});
|
||||
|
||||
test( "wrapAll(Function)", function() {
|
||||
expect( 5 );
|
||||
QUnit.test( "wrapAll(Function)", function( assert ) {
|
||||
assert.expect( 5 );
|
||||
|
||||
var prev = jQuery( "#firstp" )[ 0 ].previousSibling,
|
||||
p = jQuery( "#firstp,#first" )[ 0 ].parentNode,
|
||||
@ -157,15 +157,15 @@ test( "wrapAll(Function)", function() {
|
||||
return "<div class='red'><div class='tmp'></div></div>";
|
||||
});
|
||||
|
||||
equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
ok( jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" );
|
||||
strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" );
|
||||
assert.ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
assert.ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" );
|
||||
assert.ok( jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" );
|
||||
assert.strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
});
|
||||
|
||||
test( "wrapAll(Function) check execution characteristics", function() {
|
||||
expect( 3 );
|
||||
QUnit.test( "wrapAll(Function) check execution characteristics", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var i = 0;
|
||||
|
||||
@ -174,69 +174,69 @@ test( "wrapAll(Function) check execution characteristics", function() {
|
||||
return "";
|
||||
});
|
||||
|
||||
ok( !i, "should not execute function argument if target element does not exist" );
|
||||
assert.ok( !i, "should not execute function argument if target element does not exist" );
|
||||
|
||||
jQuery( "#firstp" ).wrapAll(function( index ) {
|
||||
strictEqual( this, jQuery( "#firstp" )[ 0 ], "context must be the first found element" );
|
||||
strictEqual( index, undefined, "index argument should not be included in function execution" );
|
||||
assert.strictEqual( this, jQuery( "#firstp" )[ 0 ], "context must be the first found element" );
|
||||
assert.strictEqual( index, undefined, "index argument should not be included in function execution" );
|
||||
});
|
||||
});
|
||||
|
||||
test( "wrapAll(Element)", function() {
|
||||
QUnit.test( "wrapAll(Element)", function( assert ) {
|
||||
|
||||
expect( 3 );
|
||||
assert.expect( 3 );
|
||||
|
||||
var prev, p;
|
||||
prev = jQuery("#firstp")[ 0 ].previousSibling;
|
||||
p = jQuery("#first")[ 0 ].parentNode;
|
||||
jQuery("#firstp,#first").wrapAll( document.getElementById("empty") );
|
||||
|
||||
equal( jQuery("#first").parent()[ 0 ], jQuery("#firstp").parent()[ 0 ], "Same Parent" );
|
||||
equal( jQuery("#first").parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
equal( jQuery("#first").parent()[ 0 ].parentNode, p, "Correct Parent" );
|
||||
assert.equal( jQuery("#first").parent()[ 0 ], jQuery("#firstp").parent()[ 0 ], "Same Parent" );
|
||||
assert.equal( jQuery("#first").parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
|
||||
assert.equal( jQuery("#first").parent()[ 0 ].parentNode, p, "Correct Parent" );
|
||||
});
|
||||
|
||||
test( "wrapInner(String)", function() {
|
||||
QUnit.test( "wrapInner(String)", function( assert ) {
|
||||
|
||||
expect( 6 );
|
||||
assert.expect( 6 );
|
||||
|
||||
var num;
|
||||
|
||||
num = jQuery("#first").children().length;
|
||||
jQuery("#first").wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
|
||||
num = jQuery("#first").html("foo<div>test</div><div>test2</div>").children().length;
|
||||
jQuery("#first").wrapInner( "<div class='red'><div id='tmp'></div></div>" );
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
});
|
||||
|
||||
test( "wrapInner(Element)", function() {
|
||||
QUnit.test( "wrapInner(Element)", function( assert ) {
|
||||
|
||||
expect( 5 );
|
||||
assert.expect( 5 );
|
||||
|
||||
var num,
|
||||
div = jQuery("<div/>");
|
||||
|
||||
num = jQuery("#first").children().length;
|
||||
jQuery("#first").wrapInner( document.getElementById("empty") );
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
|
||||
div.wrapInner( "<span></span>" );
|
||||
equal( div.children().length, 1, "The contents were wrapped." );
|
||||
equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
||||
assert.equal( div.children().length, 1, "The contents were wrapped." );
|
||||
assert.equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
||||
});
|
||||
|
||||
test( "wrapInner(Function) returns String", function() {
|
||||
QUnit.test( "wrapInner(Function) returns String", function( assert ) {
|
||||
|
||||
expect( 6 );
|
||||
assert.expect( 6 );
|
||||
|
||||
var num,
|
||||
val = manipulationFunctionReturningObj;
|
||||
@ -244,20 +244,20 @@ test( "wrapInner(Function) returns String", function() {
|
||||
num = jQuery("#first").children().length;
|
||||
jQuery("#first").wrapInner( val("<div class='red'><div id='tmp'></div></div>") );
|
||||
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
|
||||
num = jQuery("#first").html("foo<div>test</div><div>test2</div>").children().length;
|
||||
jQuery("#first").wrapInner( val("<div class='red'><div id='tmp'></div></div>") );
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is(".red"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );
|
||||
});
|
||||
|
||||
test( "wrapInner(Function) returns Element", function() {
|
||||
QUnit.test( "wrapInner(Function) returns Element", function( assert ) {
|
||||
|
||||
expect( 5 );
|
||||
assert.expect( 5 );
|
||||
|
||||
var num,
|
||||
val = manipulationFunctionReturningObj,
|
||||
@ -265,84 +265,84 @@ test( "wrapInner(Function) returns Element", function() {
|
||||
|
||||
num = jQuery("#first").children().length;
|
||||
jQuery("#first").wrapInner( val(document.getElementById("empty")) );
|
||||
equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
||||
equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
assert.equal( jQuery("#first").children().length, 1, "Only one child" );
|
||||
assert.ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );
|
||||
assert.equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" );
|
||||
|
||||
div.wrapInner( val("<span></span>") );
|
||||
equal( div.children().length, 1, "The contents were wrapped." );
|
||||
equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
||||
assert.equal( div.children().length, 1, "The contents were wrapped." );
|
||||
assert.equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." );
|
||||
});
|
||||
|
||||
test( "unwrap()", function() {
|
||||
QUnit.test( "unwrap()", function( assert ) {
|
||||
|
||||
expect( 9 );
|
||||
assert.expect( 9 );
|
||||
|
||||
jQuery("body").append(" <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> <div id='unwrap3'> <b><span class='unwrap unwrap3'>e</span></b> <b><span class='unwrap unwrap3'>f</span></b> </div> </div>");
|
||||
|
||||
var abcd = jQuery("#unwrap1 > span, #unwrap2 > span").get(),
|
||||
abcdef = jQuery("#unwrap span").get();
|
||||
|
||||
equal( jQuery("#unwrap1 span").add("#unwrap2 span:first-child").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" );
|
||||
deepEqual( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" );
|
||||
assert.equal( jQuery("#unwrap1 span").add("#unwrap2 span:first-child").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" );
|
||||
assert.deepEqual( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" );
|
||||
|
||||
deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" );
|
||||
assert.deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" );
|
||||
|
||||
deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" );
|
||||
assert.deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" );
|
||||
|
||||
deepEqual( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" );
|
||||
assert.deepEqual( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" );
|
||||
|
||||
deepEqual( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" );
|
||||
assert.deepEqual( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" );
|
||||
|
||||
deepEqual( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" );
|
||||
deepEqual( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" );
|
||||
assert.deepEqual( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" );
|
||||
assert.deepEqual( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" );
|
||||
|
||||
deepEqual( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" );
|
||||
assert.deepEqual( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" );
|
||||
|
||||
jQuery("body > span.unwrap").remove();
|
||||
});
|
||||
|
||||
test( "unwrap( selector )", function() {
|
||||
QUnit.test( "unwrap( selector )", function( assert ) {
|
||||
|
||||
expect( 5 );
|
||||
assert.expect( 5 );
|
||||
|
||||
jQuery( "body" ).append( " <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>a</span> <span class='unwrap'>b</span> </div> <div id='unwrap2'> <span class='unwrap'>c</span> <span class='unwrap'>d</span> </div> </div>" );
|
||||
|
||||
// Shouldn't unwrap, no match
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap2" );
|
||||
equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
||||
assert.equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
||||
|
||||
// Shouldn't unwrap, no match
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "span" );
|
||||
equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
||||
assert.equal( jQuery("#unwrap1").length, 1, "still wrapped" );
|
||||
|
||||
// Unwraps
|
||||
jQuery( "#unwrap1 span" ) .unwrap( "#unwrap1" );
|
||||
equal( jQuery("#unwrap1").length, 0, "unwrapped match" );
|
||||
assert.equal( jQuery("#unwrap1").length, 0, "unwrapped match" );
|
||||
|
||||
// Check return values
|
||||
deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(), "return on unmatched unwrap" );
|
||||
deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(), "return on matched unwrap" );
|
||||
assert.deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(), "return on unmatched unwrap" );
|
||||
assert.deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(), "return on matched unwrap" );
|
||||
|
||||
jQuery("body > span.unwrap").remove();
|
||||
});
|
||||
|
||||
test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function() {
|
||||
QUnit.test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function( assert ) {
|
||||
|
||||
expect( 2 );
|
||||
assert.expect( 2 );
|
||||
|
||||
var $wraptarget = jQuery( "<div id='wrap-target'>Target</div>" ).appendTo( "#qunit-fixture" ),
|
||||
$section = jQuery( "<section>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
$wraptarget.wrapAll("<aside style='background-color:green'></aside>");
|
||||
|
||||
notEqual( $wraptarget.parent("aside").get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" );
|
||||
notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" );
|
||||
assert.notEqual( $wraptarget.parent("aside").get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" );
|
||||
assert.notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" );
|
||||
});
|
||||
|
||||
test( "wrapping scripts (#10470)", function() {
|
||||
QUnit.test( "wrapping scripts (#10470)", function( assert ) {
|
||||
|
||||
expect( 2 );
|
||||
assert.expect( 2 );
|
||||
|
||||
var script = document.createElement("script");
|
||||
script.text = script.textContent = "ok( !document.eval10470, 'script evaluated once' ); document.eval10470 = true;";
|
||||
@ -350,7 +350,7 @@ test( "wrapping scripts (#10470)", function() {
|
||||
document.eval10470 = false;
|
||||
jQuery("#qunit-fixture").empty()[0].appendChild( script );
|
||||
jQuery("#qunit-fixture script").wrap("<b></b>");
|
||||
strictEqual( script.parentNode, jQuery("#qunit-fixture > b")[ 0 ], "correctly wrapped" );
|
||||
assert.strictEqual( script.parentNode, jQuery("#qunit-fixture > b")[ 0 ], "correctly wrapped" );
|
||||
jQuery( script ).remove();
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user