" )[ 0 ], "Create a table with closing tag." );
+ assert.ok( jQuery( "" )[ 0 ], "Create a div with closing tag." );
+ assert.ok( jQuery( "
" )[ 0 ], "Create a table with closing tag." );
- equal( jQuery( "element[attribute='']" ).length, 0,
+ assert.equal( jQuery( "element[attribute='']" ).length, 0,
"When html is within brackets, do not recognize as html." );
//equal( jQuery( "element[attribute=]" ).length, 0,
// "When html is within brackets, do not recognize as html." );
- equal( jQuery( "element:not()" ).length, 0,
+ assert.equal( jQuery( "element:not()" ).length, 0,
"When html is within parens, do not recognize as html." );
- equal( jQuery( "\\
" +
@@ -593,7 +593,7 @@ test( "show();", function() {
jQuery.each( test, function( selector, expected ) {
var elem = jQuery( selector, "#show-tests" ).show();
- equal( elem.css( "display" ), expected, "Show using correct display type for " + selector );
+ assert.equal( elem.css( "display" ), expected, "Show using correct display type for " + selector );
} );
// Make sure that showing or hiding a text node doesn't cause an error
@@ -601,73 +601,73 @@ test( "show();", function() {
jQuery( "
test
text test" ).hide().remove();
} );
-test( "show() resolves correct default display for detached nodes", function() {
- expect( 16 );
+QUnit.test( "show() resolves correct default display for detached nodes", function( assert ) {
+ assert.expect( 16 );
var div, span, tr;
div = jQuery( "
" );
div.show().appendTo( "#qunit-fixture" );
- equal( div.css( "display" ), "none",
+ assert.equal( div.css( "display" ), "none",
"A shown-while-detached div can be hidden by the CSS cascade" );
div = jQuery( "
" ).children( "div" );
div.show().appendTo( "#qunit-fixture" );
- equal( div.css( "display" ), "none",
+ assert.equal( div.css( "display" ), "none",
"A shown-while-detached div inside a visible div can be hidden by the CSS cascade" );
span = jQuery( "" );
span.show().appendTo( "#qunit-fixture" );
- equal( span.css( "display" ), "none",
+ assert.equal( span.css( "display" ), "none",
"A shown-while-detached span can be hidden by the CSS cascade" );
div = jQuery( "div.hidden" );
div.detach().show();
- ok( !div[ 0 ].style.display,
+ assert.ok( !div[ 0 ].style.display,
"show() does not update inline style of a cascade-hidden-before-detach div" );
div.appendTo( "#qunit-fixture" );
- equal( div.css( "display" ), "none",
+ assert.equal( div.css( "display" ), "none",
"A shown-while-detached cascade-hidden div is hidden after attachment" );
div.remove();
span = jQuery( "" );
span.appendTo( "#qunit-fixture" ).detach().show().appendTo( "#qunit-fixture" );
- equal( span.css( "display" ), "none",
+ assert.equal( span.css( "display" ), "none",
"A shown-while-detached cascade-hidden span is hidden after attachment" );
span.remove();
div = jQuery( document.createElement( "div" ) );
div.show().appendTo( "#qunit-fixture" );
- ok( !div[ 0 ].style.display, "A shown-while-detached div has no inline style" );
- equal( div.css( "display" ), "block",
+ assert.ok( !div[ 0 ].style.display, "A shown-while-detached div has no inline style" );
+ assert.equal( div.css( "display" ), "block",
"A shown-while-detached div has default display after attachment" );
div.remove();
div = jQuery( "
" );
div.show();
- equal( div[ 0 ].style.display, "",
+ assert.equal( div[ 0 ].style.display, "",
"show() updates inline style of a detached inline-hidden div" );
div.appendTo( "#qunit-fixture" );
- equal( div.css( "display" ), "block",
+ assert.equal( div.css( "display" ), "block",
"A shown-while-detached inline-hidden div has default display after attachment" );
div = jQuery( "
" ).appendTo( "#qunit-fixture" );
x = div.find( "div" );
- strictEqual( x.toggle().css( "display" ), "none", "is hidden" );
- strictEqual( x.toggle().css( "display" ), "block", "is visible" );
+ assert.strictEqual( x.toggle().css( "display" ), "none", "is hidden" );
+ assert.strictEqual( x.toggle().css( "display" ), "block", "is visible" );
// Ensure hide() is called when toggled (#12148)
oldHide = jQuery.fn.hide;
jQuery.fn.hide = function() {
- ok( true, name + " method called on toggle" );
+ assert.ok( true, name + " method called on toggle" );
return oldHide.apply( this, arguments );
};
x.toggle( name === "show" );
jQuery.fn.hide = oldHide;
} );
-test( "hide hidden elements (bug #7141)", function() {
- expect( 3 );
+QUnit.test( "hide hidden elements (bug #7141)", function( assert ) {
+ assert.expect( 3 );
var div = jQuery( "" ).appendTo( "#qunit-fixture" );
- equal( div.css( "display" ), "none", "Element is hidden by default" );
+ assert.equal( div.css( "display" ), "none", "Element is hidden by default" );
div.hide();
- ok( !jQuery._data( div, "display" ), "display data is undefined after hiding an already-hidden element" );
+ assert.ok( !jQuery._data( div, "display" ), "display data is undefined after hiding an already-hidden element" );
div.show();
- equal( div.css( "display" ), "block", "Show a double-hidden element" );
+ assert.equal( div.css( "display" ), "block", "Show a double-hidden element" );
div.remove();
} );
-test( "jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function() {
- expect( 4 );
+QUnit.test( "jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function( assert ) {
+ assert.expect( 4 );
var $checkedtest = jQuery( "#checkedtest" );
jQuery.css( $checkedtest[ 0 ], "height" );
- ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." );
- ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." );
- ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." );
- ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." );
+ assert.ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." );
+ assert.ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." );
+ assert.ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." );
+ assert.ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." );
} );
-test( "internal ref to elem.runtimeStyle (bug #7608)", function() {
- expect( 1 );
+QUnit.test( "internal ref to elem.runtimeStyle (bug #7608)", function( assert ) {
+ assert.expect( 1 );
var result = true;
try {
@@ -751,11 +751,11 @@ test( "internal ref to elem.runtimeStyle (bug #7608)", function() {
result = false;
}
- ok( result, "elem.runtimeStyle does not throw exception" );
+ assert.ok( result, "elem.runtimeStyle does not throw exception" );
} );
-test( "marginRight computed style (bug #3333)", function() {
- expect( 1 );
+QUnit.test( "marginRight computed style (bug #3333)", function( assert ) {
+ assert.expect( 1 );
var $div = jQuery( "#foo" );
$div.css( {
@@ -763,22 +763,22 @@ test( "marginRight computed style (bug #3333)", function() {
"marginRight": 0
} );
- equal( $div.css( "marginRight" ), "0px", "marginRight correctly calculated with a width and display block" );
+ assert.equal( $div.css( "marginRight" ), "0px", "marginRight correctly calculated with a width and display block" );
} );
-test( "box model properties incorrectly returning % instead of px, see #10639 and #12088", function() {
- expect( 2 );
+QUnit.test( "box model properties incorrectly returning % instead of px, see #10639 and #12088", function( assert ) {
+ assert.expect( 2 );
var container = jQuery( "" ).width( 400 ).appendTo( "#qunit-fixture" ),
el = jQuery( "" ).css( { "width": "50%", "marginRight": "50%" } ).appendTo( container ),
el2 = jQuery( "" ).css( { "width": "50%", "minWidth": "300px", "marginLeft": "25%" } ).appendTo( container );
- equal( el.css( "marginRight" ), "200px", "css('marginRight') returning % instead of px, see #10639" );
- equal( el2.css( "marginLeft" ), "100px", "css('marginLeft') returning incorrect pixel value, see #12088" );
+ assert.equal( el.css( "marginRight" ), "200px", "css('marginRight') returning % instead of px, see #10639" );
+ assert.equal( el2.css( "marginLeft" ), "100px", "css('marginLeft') returning incorrect pixel value, see #12088" );
} );
-test( "jQuery.cssProps behavior, (bug #8402)", function() {
- expect( 2 );
+QUnit.test( "jQuery.cssProps behavior, (bug #8402)", function( assert ) {
+ assert.expect( 2 );
var div = jQuery( "
" ).appendTo( document.body ).css( {
"position": "absolute",
@@ -786,49 +786,49 @@ test( "jQuery.cssProps behavior, (bug #8402)", function() {
"left": 10
} );
jQuery.cssProps.top = "left";
- equal( div.css( "top" ), "10px", "the fixed property is used when accessing the computed style" );
+ assert.equal( div.css( "top" ), "10px", "the fixed property is used when accessing the computed style" );
div.css( "top", "100px" );
- equal( div[ 0 ].style.left, "100px", "the fixed property is used when setting the style" );
+ assert.equal( div[ 0 ].style.left, "100px", "the fixed property is used when setting the style" );
// cleanup jQuery.cssProps
jQuery.cssProps.top = undefined;
} );
-test( "widows & orphans #8936", function() {
+QUnit.test( "widows & orphans #8936", function( assert ) {
var $p = jQuery( "
" ).appendTo( "#qunit-fixture" );
if ( "widows" in $p[ 0 ].style ) {
- expect( 2 );
+ assert.expect( 2 );
$p.css( {
"widows": 3,
"orphans": 3
} );
- equal( $p.css( "widows" ) || jQuery.style( $p[ 0 ], "widows" ), 3, "widows correctly set to 3" );
- equal( $p.css( "orphans" ) || jQuery.style( $p[ 0 ], "orphans" ), 3, "orphans correctly set to 3" );
+ assert.equal( $p.css( "widows" ) || jQuery.style( $p[ 0 ], "widows" ), 3, "widows correctly set to 3" );
+ assert.equal( $p.css( "orphans" ) || jQuery.style( $p[ 0 ], "orphans" ), 3, "orphans correctly set to 3" );
} else {
- expect( 1 );
- ok( true, "jQuery does not attempt to test for style props that definitely don't exist in older versions of IE" );
+ assert.expect( 1 );
+ assert.ok( true, "jQuery does not attempt to test for style props that definitely don't exist in older versions of IE" );
}
$p.remove();
} );
-test( "can't get css for disconnected in IE<9, see #10254 and #8388", function() {
- expect( 2 );
+QUnit.test( "can't get css for disconnected in IE<9, see #10254 and #8388", function( assert ) {
+ assert.expect( 2 );
var span, div;
span = jQuery( "" ).css( "background-image", "url(data/1x1.jpg)" );
- notEqual( span.css( "background-image" ), null, "can't get background-image in IE<9, see #10254" );
+ assert.notEqual( span.css( "background-image" ), null, "can't get background-image in IE<9, see #10254" );
div = jQuery( "
" ).css( "top", 10 );
- equal( div.css( "top" ), "10px", "can't get top in IE<9, see #8388" );
+ assert.equal( div.css( "top" ), "10px", "can't get top in IE<9, see #8388" );
} );
-test( "can't get background-position in IE<9, see #10796", function() {
+QUnit.test( "can't get background-position in IE<9, see #10796", function( assert ) {
var div = jQuery( "" ).appendTo( "#qunit-fixture" ),
units = [
"0 0",
@@ -843,33 +843,33 @@ test( "can't get background-position in IE<9, see #10796", function() {
l = units.length,
i = 0;
- expect( l );
+ assert.expect( l );
for ( ; i < l; i++ ) {
div.css( "background-position", units [ i ] );
- ok( div.css( "background-position" ), "can't get background-position in IE<9, see #10796" );
+ assert.ok( div.css( "background-position" ), "can't get background-position in IE<9, see #10796" );
}
} );
-test( "percentage properties for bottom and right in IE<9 should not be incorrectly transformed to pixels, see #11311", function() {
- expect( 1 );
+QUnit.test( "percentage properties for bottom and right in IE<9 should not be incorrectly transformed to pixels, see #11311", function( assert ) {
+ assert.expect( 1 );
var div = jQuery( "" ).appendTo( "#qunit-fixture" );
- ok( window.getComputedStyle || div.css( "bottom" ) === "50%", "position properties get incorrectly transformed in IE<8, see #11311" );
+ assert.ok( window.getComputedStyle || div.css( "bottom" ) === "50%", "position properties get incorrectly transformed in IE<8, see #11311" );
} );
if ( jQuery.fn.offset ) {
- test( "percentage properties for left and top should be transformed to pixels, see #9505", function() {
- expect( 2 );
+ QUnit.test( "percentage properties for left and top should be transformed to pixels, see #9505", function( assert ) {
+ assert.expect( 2 );
var parent = jQuery( "" ).appendTo( "#qunit-fixture" ),
div = jQuery( "" ).appendTo( parent );
- equal( div.css( "top" ), "100px", "position properties not transformed to pixels, see #9505" );
- equal( div.css( "left" ), "100px", "position properties not transformed to pixels, see #9505" );
+ assert.equal( div.css( "top" ), "100px", "position properties not transformed to pixels, see #9505" );
+ assert.equal( div.css( "left" ), "100px", "position properties not transformed to pixels, see #9505" );
} );
}
-test( "Do not append px (#9548, #12990)", function() {
- expect( 2 );
+QUnit.test( "Do not append px (#9548, #12990)", function( assert ) {
+ assert.expect( 2 );
var $div = jQuery( "
" ).appendTo( "#qunit-fixture" );
@@ -877,37 +877,38 @@ test( "Do not append px (#9548, #12990)", function() {
// Support: Android 2.3 (no support for fill-opacity)
if ( $div.css( "fill-opacity" ) ) {
- equal( $div.css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
+ assert.equal( $div.css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
} else {
- ok( true, "No support for fill-opacity CSS property" );
+ assert.ok( true, "No support for fill-opacity CSS property" );
}
$div.css( "column-count", 1 );
if ( $div.css( "column-count" ) ) {
- equal( $div.css( "column-count" ), 1, "Do not append px to 'column-count'" );
+ assert.equal( $div.css( "column-count" ), 1, "Do not append px to 'column-count'" );
} else {
- ok( true, "No support for column-count CSS property" );
+ assert.ok( true, "No support for column-count CSS property" );
}
} );
-test( "css('width') and css('height') should respect box-sizing, see #11004", function() {
- expect( 4 );
+QUnit.test( "css('width') and css('height') should respect box-sizing, see #11004", function( assert ) {
+ assert.expect( 4 );
// Support: Android 2.3 (-webkit-box-sizing).
var el_dis = jQuery( "
test
" ),
el = el_dis.clone().appendTo( "#qunit-fixture" );
- equal( el.css( "width" ), el.css( "width", el.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing, see #11004" );
- equal( el_dis.css( "width" ), el_dis.css( "width", el_dis.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing for disconnected element, see #11004" );
- equal( el.css( "height" ), el.css( "height", el.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing, see #11004" );
- equal( el_dis.css( "height" ), el_dis.css( "height", el_dis.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing for disconnected element, see #11004" );
+ assert.equal( el.css( "width" ), el.css( "width", el.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing, see #11004" );
+ assert.equal( el_dis.css( "width" ), el_dis.css( "width", el_dis.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing for disconnected element, see #11004" );
+ assert.equal( el.css( "height" ), el.css( "height", el.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing, see #11004" );
+ assert.equal( el_dis.css( "height" ), el_dis.css( "height", el_dis.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing for disconnected element, see #11004" );
} );
-testIframeWithCallback( "css('width') should work correctly before document ready (#14084)",
+testIframeWithCallback(
+ "css('width') should work correctly before document ready (#14084)",
"css/cssWidthBeforeDocReady.html",
- function( cssWidthBeforeDocReady ) {
- expect( 1 );
- strictEqual( cssWidthBeforeDocReady, "100px", "elem.css('width') works correctly before document ready" );
+ function( cssWidthBeforeDocReady, assert ) {
+ assert.expect( 1 );
+ assert.strictEqual( cssWidthBeforeDocReady, "100px", "elem.css('width') works correctly before document ready" );
}
);
@@ -921,63 +922,63 @@ testIframeWithCallback( "css('width') should work correctly before document read
div.getBoundingClientRect().width.toFixed( 1 ) === "3.3";
qunitFixture.removeChild( div );
- test( "css('width') and css('height') should return fractional values for nodes in the document", function() {
+ QUnit.test( "css('width') and css('height') should return fractional values for nodes in the document", function( assert ) {
if ( !supportsFractionalGBCR ) {
- expect( 1 );
- ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" );
+ assert.expect( 1 );
+ assert.ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" );
return;
}
- expect( 2 );
+ assert.expect( 2 );
var el = jQuery( "" ).appendTo( "#qunit-fixture" );
jQuery( "" ).appendTo( "#qunit-fixture" );
- equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3",
+ assert.equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3",
"css('width') should return fractional values" );
- equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8",
+ assert.equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8",
"css('height') should return fractional values" );
} );
- test( "css('width') and css('height') should return fractional values for disconnected nodes", function() {
+ QUnit.test( "css('width') and css('height') should return fractional values for disconnected nodes", function( assert ) {
if ( !supportsFractionalGBCR ) {
- expect( 1 );
- ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" );
+ assert.expect( 1 );
+ assert.ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" );
return;
}
- expect( 2 );
+ assert.expect( 2 );
var el = jQuery( "" );
- equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3",
+ assert.equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3",
"css('width') should return fractional values" );
- equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8",
+ assert.equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8",
"css('height') should return fractional values" );
} );
} )();
-test( "certain css values of 'normal' should be convertable to a number, see #8627", function() {
+QUnit.test( "certain css values of 'normal' should be convertable to a number, see #8627", function( assert ) {
expect ( 3 );
var el = jQuery( "
test
" ).appendTo( "#qunit-fixture" );
- ok( jQuery.isNumeric( parseFloat( el.css( "letterSpacing" ) ) ), "css('letterSpacing') not convertable to number, see #8627" );
- ok( jQuery.isNumeric( parseFloat( el.css( "fontWeight" ) ) ), "css('fontWeight') not convertable to number, see #8627" );
- equal( typeof el.css( "fontWeight" ), "string", ".css() returns a string" );
+ assert.ok( jQuery.isNumeric( parseFloat( el.css( "letterSpacing" ) ) ), "css('letterSpacing') not convertable to number, see #8627" );
+ assert.ok( jQuery.isNumeric( parseFloat( el.css( "fontWeight" ) ) ), "css('fontWeight') not convertable to number, see #8627" );
+ assert.equal( typeof el.css( "fontWeight" ), "string", ".css() returns a string" );
} );
// only run this test in IE9
if ( document.documentMode === 9 ) {
- test( ".css('filter') returns a string in IE9, see #12537", function() {
- expect( 1 );
+ QUnit.test( ".css('filter') returns a string in IE9, see #12537", function( assert ) {
+ assert.expect( 1 );
- equal( jQuery( "" ).css( "filter" ), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)", "IE9 returns the correct value from css('filter')." );
+ assert.equal( jQuery( "" ).css( "filter" ), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)", "IE9 returns the correct value from css('filter')." );
} );
}
-test( "cssHooks - expand", function() {
- expect( 15 );
+QUnit.test( "cssHooks - expand", function( assert ) {
+ assert.expect( 15 );
var result,
properties = {
margin: [ "marginTop", "marginRight", "marginBottom", "marginLeft" ],
@@ -992,32 +993,32 @@ test( "cssHooks - expand", function() {
expected[ key ] = 10;
} );
result = hook.expand( 10 );
- deepEqual( result, expected, property + " expands properly with a number" );
+ assert.deepEqual( result, expected, property + " expands properly with a number" );
jQuery.each( keys, function( _, key ) {
expected[ key ] = "10px";
} );
result = hook.expand( "10px" );
- deepEqual( result, expected, property + " expands properly with '10px'" );
+ assert.deepEqual( result, expected, property + " expands properly with '10px'" );
expected[ keys[ 1 ] ] = expected[ keys[ 3 ] ] = "20px";
result = hook.expand( "10px 20px" );
- deepEqual( result, expected, property + " expands properly with '10px 20px'" );
+ assert.deepEqual( result, expected, property + " expands properly with '10px 20px'" );
expected[ keys[ 2 ] ] = "30px";
result = hook.expand( "10px 20px 30px" );
- deepEqual( result, expected, property + " expands properly with '10px 20px 30px'" );
+ assert.deepEqual( result, expected, property + " expands properly with '10px 20px 30px'" );
expected[ keys[ 3 ] ] = "40px";
result = hook.expand( "10px 20px 30px 40px" );
- deepEqual( result, expected, property + " expands properly with '10px 20px 30px 40px'" );
+ assert.deepEqual( result, expected, property + " expands properly with '10px 20px 30px 40px'" );
} );
} );
-test( "css opacity consistency across browsers (#12685)", function() {
- expect( 4 );
+QUnit.test( "css opacity consistency across browsers (#12685)", function( assert ) {
+ assert.expect( 4 );
var el,
fixture = jQuery( "#qunit-fixture" );
@@ -1027,39 +1028,39 @@ test( "css opacity consistency across browsers (#12685)", function() {
el = jQuery( "" ).appendTo( fixture );
- equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (-ms-filter:alpha with spaces)" );
+ assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (-ms-filter:alpha with spaces)" );
el.removeClass( "opacityWithSpaces_t12685" ).addClass( "opacityNoSpaces_t12685" );
- equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (-ms-filter:alpha without spaces)" );
+ assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (-ms-filter:alpha without spaces)" );
el.css( "opacity", 0.3 );
- equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override opacity" );
+ assert.equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override opacity" );
el.css( "opacity", "" );
- equal( Math.round( el.css( "opacity" ) * 100 ), 20, "remove opacity override" );
+ assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "remove opacity override" );
} );
-test( ":visible/:hidden selectors", function() {
- expect( 17 );
+QUnit.test( ":visible/:hidden selectors", function( assert ) {
+ assert.expect( 17 );
var $div, $table, $a;
- ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" );
+ assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" );
jQuery( "#nothiddendiv" ).css( { display: "none" } );
- ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" );
+ assert.ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" );
jQuery( "#nothiddendiv" ).css( { "display": "block" } );
- ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" );
- ok( !jQuery( window ).is( ":visible" ), "Calling is(':visible') on window does not throw an exception (#10267)." );
- ok( !jQuery( document ).is( ":visible" ), "Calling is(':visible') on document does not throw an exception (#10267)." );
+ assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" );
+ assert.ok( !jQuery( window ).is( ":visible" ), "Calling is(':visible') on window does not throw an exception (#10267)." );
+ assert.ok( !jQuery( document ).is( ":visible" ), "Calling is(':visible') on document does not throw an exception (#10267)." );
- ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" );
+ assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" );
jQuery( "#nothiddendiv" ).css( "display", "none" );
- ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" );
+ assert.ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" );
jQuery( "#nothiddendiv" ).css( "display", "block" );
- ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" );
+ assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" );
- ok( jQuery( "#siblingspan" ).is( ":visible" ), "Span with no content is visible" );
+ assert.ok( jQuery( "#siblingspan" ).is( ":visible" ), "Span with no content is visible" );
$div = jQuery( "
" ).appendTo( "#qunit-fixture" );
- equal( $div.find( ":visible" ).length, 1, "Span with no content is visible" );
+ assert.equal( $div.find( ":visible" ).length, 1, "Span with no content is visible" );
$div.css( { width: 0, height: 0, overflow: "hidden" } );
- ok( $div.is( ":visible" ), "Div with width and height of 0 is still visible (gh-2227)" );
+ assert.ok( $div.is( ":visible" ), "Div with width and height of 0 is still visible (gh-2227)" );
// Safari 6-7 and iOS 6-7 report 0 width for br elements
// When newer browsers propagate, re-enable this test
@@ -1068,39 +1069,39 @@ test( ":visible/:hidden selectors", function() {
$table = jQuery( "#table" );
$table.html( "
cell
cell
" );
- equal( jQuery( "#table td:visible" ).length, 1, "hidden cell is not perceived as visible (#4512). Works on table elements" );
+ assert.equal( jQuery( "#table td:visible" ).length, 1, "hidden cell is not perceived as visible (#4512). Works on table elements" );
$table.css( "display", "none" ).html( "
cell
cell
" );
- equal( jQuery( "#table td:visible" ).length, 0, "hidden cell children not perceived as visible (#4512)" );
+ assert.equal( jQuery( "#table td:visible" ).length, 0, "hidden cell children not perceived as visible (#4512)" );
t( "Is Visible", "#qunit-fixture div:visible:lt(2)", [ "foo", "nothiddendiv" ] );
t( "Is Not Hidden", "#qunit-fixture:hidden", [] );
t( "Is Hidden", "#form input:hidden", [ "hidden1","hidden2" ] );
$a = jQuery( "
" );
// 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 ], "display" );
} );
-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( "
" );
// 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 ], "display" );
} );
-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( "
" ).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/Wid
$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( "
" ).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( "
" ).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 ac
$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,95 +392,103 @@ test( "outerHeight()", function() {
div = jQuery( "
" );
// 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 ], "display" );
} );
-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( "
test
" ).appendTo( "#qunit-fixture" ),
el = jQuery( "
test
" ).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/documentSmall", "window vs. small document", function( jQuery, window, document ) {
+testIframe(
+ "dimensions/documentSmall",
+ "window vs. small document",
+ function( jQuery, window, document, assert ) {
- // this test is practically tautological, but there is a bug in IE8
- // with no simple workaround, so this test exposes the bug and works around it
- if ( document.body.offsetWidth >= document.documentElement.offsetWidth ) {
- expect( 2 );
+ // this test is practically tautological, but there is a bug in IE8
+ // with no simple workaround, so this test exposes the bug and works around it
+ if ( document.body.offsetWidth >= document.documentElement.offsetWidth ) {
+ assert.expect( 2 );
- equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height" );
- equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width" );
- } else {
+ assert.equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height" );
+ assert.equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width" );
+ } else {
- // all tests should have at least one assertion
- expect( 1 );
- ok( true, "skipping test (conditions not satisfied)" );
+ // all tests should have at least one assertion
+ assert.expect( 1 );
+ assert.ok( true, "skipping test (conditions not satisfied)" );
+ }
}
-} );
+);
-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( "" ).appendTo( "#qunit-fixture" );
@@ -492,7 +500,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 + ")" );
} );
diff --git a/test/unit/effects.js b/test/unit/effects.js
index f4bd9c145..31822274c 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -7,7 +7,7 @@ if ( !jQuery.fx ) {
var oldRaf = window.requestAnimationFrame;
-module( "effects", {
+QUnit.module( "effects", {
setup: function() {
window.requestAnimationFrame = null;
this.sandbox = sinon.sandbox.create();
@@ -25,36 +25,36 @@ module( "effects", {
}
} );
-test( "sanity check", function() {
- expect( 1 );
- equal( jQuery( "#dl:visible, #qunit-fixture:visible, #foo:visible" ).length, 3, "QUnit state is correct for testing effects" );
+QUnit.test( "sanity check", function( assert ) {
+ assert.expect( 1 );
+ assert.equal( jQuery( "#dl:visible, #qunit-fixture:visible, #foo:visible" ).length, 3, "QUnit state is correct for testing effects" );
} );
-test( "show() basic", function() {
- expect( 1 );
+QUnit.test( "show() basic", function( assert ) {
+ assert.expect( 1 );
var div = jQuery( "
" )
.appendTo( "#qunit-fixture" ).children( "div" );
$div.animate( { width: "25%", height: "25%" }, 13, function() {
var $this = jQuery( this );
- equal( $this.css( "width" ), "15px", "Width was animated to 15px rather than 25px" );
- equal( $this.css( "height" ), "15px", "Height was animated to 15px rather than 25px" );
+ assert.equal( $this.css( "width" ), "15px", "Width was animated to 15px rather than 25px" );
+ assert.equal( $this.css( "height" ), "15px", "Height was animated to 15px rather than 25px" );
} );
this.clock.tick( 20 );
} );
-test( "animate resets overflow-x and overflow-y when finished", function() {
- expect( 2 );
+QUnit.test( "animate resets overflow-x and overflow-y when finished", function( assert ) {
+ assert.expect( 2 );
jQuery( "#foo" )
.css( { display: "block", width: 20, height: 20, overflowX: "visible", overflowY: "auto" } )
.animate( { width: 42, height: 42 }, 100, function() {
- equal( this.style.overflowX, "visible", "overflow-x is visible" );
- equal( this.style.overflowY, "auto", "overflow-y is auto" );
+ assert.equal( this.style.overflowX, "visible", "overflow-x is visible" );
+ assert.equal( this.style.overflowY, "auto", "overflow-y is auto" );
} );
this.clock.tick( 100 );
} );
/* // This test ends up being flaky depending upon the CPU load
-test("animate option (queue === false)", function () {
- expect(1);
- stop();
+QUnit.test("animate option (queue === false)", function( assert ) {
+ assert.expect(1);
+ QUnit.stop();
var order = [];
@@ -443,8 +443,8 @@ test("animate option (queue === false)", function () {
$foo.animate({width:"100px"}, 3000, function () {
// should finish after unqueued animation so second
order.push(2);
- deepEqual( order, [ 1, 2 ], "Animations finished in the correct order" );
- start();
+ assert.deepEqual( order, [ 1, 2 ], "Animations finished in the correct order" );
+ QUnit.start();
});
$foo.animate({fontSize:"2em"}, {queue:false, duration:10, complete:function () {
// short duration and out of queue so should finish first
@@ -453,8 +453,8 @@ test("animate option (queue === false)", function () {
});
*/
-test( "animate option { queue: false }", function() {
- expect( 2 );
+QUnit.test( "animate option { queue: false }", function( assert ) {
+ assert.expect( 2 );
var foo = jQuery( "#foo" );
foo.animate( {
@@ -463,16 +463,16 @@ test( "animate option { queue: false }", function() {
queue: false,
duration: 10,
complete: function() {
- ok( true, "Animation Completed" );
+ assert.ok( true, "Animation Completed" );
}
} );
this.clock.tick( 10 );
- equal( foo.queue().length, 0, "Queue is empty" );
+ assert.equal( foo.queue().length, 0, "Queue is empty" );
} );
-test( "animate option { queue: true }", function() {
- expect( 2 );
+QUnit.test( "animate option { queue: true }", function( assert ) {
+ assert.expect( 2 );
var foo = jQuery( "#foo" );
foo.animate( {
@@ -481,18 +481,18 @@ test( "animate option { queue: true }", function() {
queue: true,
duration: 10,
complete: function() {
- ok( true, "Animation Completed" );
+ assert.ok( true, "Animation Completed" );
}
} );
- notEqual( foo.queue().length, 0, "Default queue is not empty" );
+ assert.notEqual( foo.queue().length, 0, "Default queue is not empty" );
//clear out existing timers before next test
this.clock.tick( 10 );
} );
-test( "animate option { queue: 'name' }", function() {
- expect( 5 );
+QUnit.test( "animate option { queue: 'name' }", function( assert ) {
+ assert.expect( 5 );
var foo = jQuery( "#foo" ),
origWidth = parseFloat( foo.css( "width" ) ),
order = [];
@@ -504,27 +504,27 @@ test( "animate option { queue: 'name' }", function() {
// second callback function
order.push( 2 );
- equal( parseFloat( foo.css( "width" ) ), origWidth + 100, "Animation ended" );
- equal( foo.queue( "name" ).length, 1, "Queue length of 'name' queue" );
+ assert.equal( parseFloat( foo.css( "width" ) ), origWidth + 100, "Animation ended" );
+ assert.equal( foo.queue( "name" ).length, 1, "Queue length of 'name' queue" );
}
} ).queue( "name", function() {
// last callback function
- deepEqual( order, [ 1, 2 ], "Callbacks in expected order" );
+ assert.deepEqual( order, [ 1, 2 ], "Callbacks in expected order" );
} );
// this is the first callback function that should be called
order.push( 1 );
- equal( parseFloat( foo.css( "width" ) ), origWidth, "Animation does not start on its own." );
- equal( foo.queue( "name" ).length, 2, "Queue length of 'name' queue" );
+ assert.equal( parseFloat( foo.css( "width" ) ), origWidth, "Animation does not start on its own." );
+ assert.equal( foo.queue( "name" ).length, 2, "Queue length of 'name' queue" );
foo.dequeue( "name" );
this.clock.tick( 10 );
} );
-test( "animate with no properties", function() {
- expect( 2 );
+QUnit.test( "animate with no properties", function( assert ) {
+ assert.expect( 2 );
var foo,
divs = jQuery( "div" ),
@@ -534,74 +534,74 @@ test( "animate with no properties", function() {
count++;
} );
- equal( divs.length, count, "Make sure that callback is called for each element in the set." );
+ assert.equal( divs.length, count, "Make sure that callback is called for each element in the set." );
foo = jQuery( "#foo" );
foo.animate( {} );
foo.animate( { top: 10 }, 100, function() {
- ok( true, "Animation was properly dequeued." );
+ assert.ok( true, "Animation was properly dequeued." );
} );
this.clock.tick( 100 );
} );
-test( "animate duration 0", function() {
- expect( 11 );
+QUnit.test( "animate duration 0", function( assert ) {
+ assert.expect( 11 );
var $elem,
$elems = jQuery( [ { a:0 },{ a:0 } ] ),
counter = 0;
- equal( jQuery.timers.length, 0, "Make sure no animation was running from another test" );
+ assert.equal( jQuery.timers.length, 0, "Make sure no animation was running from another test" );
$elems.eq( 0 ).animate( { a:1 }, 0, function() {
- ok( true, "Animate a simple property." );
+ assert.ok( true, "Animate a simple property." );
counter++;
} );
// Failed until [6115]
- equal( jQuery.timers.length, 0, "Make sure synchronic animations are not left on jQuery.timers" );
+ assert.equal( jQuery.timers.length, 0, "Make sure synchronic animations are not left on jQuery.timers" );
- equal( counter, 1, "One synchronic animations" );
+ assert.equal( counter, 1, "One synchronic animations" );
$elems.animate( { a:2 }, 0, function() {
- ok( true, "Animate a second simple property." );
+ assert.ok( true, "Animate a second simple property." );
counter++;
} );
- equal( counter, 3, "Multiple synchronic animations" );
+ assert.equal( counter, 3, "Multiple synchronic animations" );
$elems.eq( 0 ).animate( { a:3 }, 0, function() {
- ok( true, "Animate a third simple property." );
+ assert.ok( true, "Animate a third simple property." );
counter++;
} );
$elems.eq( 1 ).animate( { a:3 }, 200, function() {
counter++;
// Failed until [6115]
- equal( counter, 5, "One synchronic and one asynchronic" );
+ assert.equal( counter, 5, "One synchronic and one asynchronic" );
} );
this.clock.tick( 200 );
$elem = jQuery( "" );
$elem.show( 0, function() {
- ok( true, "Show callback with no duration" );
+ assert.ok( true, "Show callback with no duration" );
} );
$elem.hide( 0, function() {
- ok( true, "Hide callback with no duration" );
+ assert.ok( true, "Hide callback with no duration" );
} );
// manually clean up detached elements
$elem.remove();
} );
-test( "animate hyphenated properties", function() {
- expect( 1 );
+QUnit.test( "animate hyphenated properties", function( assert ) {
+ assert.expect( 1 );
jQuery( "#foo" )
.css( "font-size", 10 )
.animate( { "font-size": 20 }, 200, function() {
- equal( this.style.fontSize, "20px", "The font-size property was animated." );
+ assert.equal( this.style.fontSize, "20px", "The font-size property was animated." );
} );
// FIXME why is this double only when run with other tests
@@ -609,19 +609,19 @@ test( "animate hyphenated properties", function() {
} );
-test( "animate non-element", function() {
- expect( 1 );
+QUnit.test( "animate non-element", function( assert ) {
+ assert.expect( 1 );
var obj = { test: 0 };
jQuery( obj ).animate( { test: 200 }, 200, function() {
- equal( obj.test, 200, "The custom property should be modified." );
+ assert.equal( obj.test, 200, "The custom property should be modified." );
} );
this.clock.tick( 200 );
} );
-test( "stop()", function() {
- expect( 4 );
+QUnit.test( "stop()", function( assert ) {
+ assert.expect( 4 );
var $one, $two,
$foo = jQuery( "#foo" ),
@@ -633,17 +633,17 @@ test( "stop()", function() {
this.clock.tick( 100 );
nw = $foo.css( "width" );
- notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px" );
+ assert.notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px" );
$foo.stop();
nw = $foo.css( "width" );
- notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px" );
+ assert.notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px" );
this.clock.tick( 100 );
$foo.removeData();
$foo.removeData( undefined, true );
- equal( nw, $foo.css( "width" ), "The animation didn't continue" );
+ assert.equal( nw, $foo.css( "width" ), "The animation didn't continue" );
$one = jQuery( "#fadein" );
$two = jQuery( "#show" );
@@ -652,7 +652,7 @@ test( "stop()", function() {
} );
this.clock.tick( 100 );
$two.fadeTo( 100, 0, function() {
- equal( $two.css( "opacity" ), "0", "Stop does not interfere with animations on other elements (#6641)" );
+ assert.equal( $two.css( "opacity" ), "0", "Stop does not interfere with animations on other elements (#6641)" );
// Reset styles
$one.add( $two ).css( "opacity", "" );
@@ -660,8 +660,8 @@ test( "stop()", function() {
this.clock.tick( 100 );
} );
-test( "stop() - several in queue", function() {
- expect( 5 );
+QUnit.test( "stop() - several in queue", function( assert ) {
+ assert.expect( 5 );
var nw, $foo = jQuery( "#foo" );
@@ -675,23 +675,23 @@ test( "stop() - several in queue", function() {
this.clock.tick( 1 );
jQuery.fx.tick();
- equal( $foo.queue().length, 3, "3 in the queue" );
+ assert.equal( $foo.queue().length, 3, "3 in the queue" );
nw = $foo.css( "width" );
- notEqual( parseFloat( nw ), 1, "An animation occurred " + nw );
+ assert.notEqual( parseFloat( nw ), 1, "An animation occurred " + nw );
$foo.stop();
- equal( $foo.queue().length, 2, "2 in the queue" );
+ assert.equal( $foo.queue().length, 2, "2 in the queue" );
nw = $foo.css( "width" );
- notEqual( parseFloat( nw ), 1, "Stop didn't reset the animation " + nw );
+ assert.notEqual( parseFloat( nw ), 1, "Stop didn't reset the animation " + nw );
$foo.stop( true );
- equal( $foo.queue().length, 0, "0 in the queue" );
+ assert.equal( $foo.queue().length, 0, "0 in the queue" );
} );
-test( "stop(clearQueue)", function() {
- expect( 4 );
+QUnit.test( "stop(clearQueue)", function( assert ) {
+ assert.expect( 4 );
var $foo = jQuery( "#foo" ),
w = 0,
@@ -703,19 +703,19 @@ test( "stop(clearQueue)", function() {
$foo.animate( { "width": "show" }, 1000 );
this.clock.tick( 100 );
nw = $foo.css( "width" );
- ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px" );
+ assert.ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px" );
$foo.stop( true );
nw = $foo.css( "width" );
- ok( parseFloat( nw ) !== w, "Stop didn't reset the animation " + nw + " " + w + "px" );
+ assert.ok( parseFloat( nw ) !== w, "Stop didn't reset the animation " + nw + " " + w + "px" );
- equal( $foo.queue().length, 0, "The animation queue was cleared" );
+ assert.equal( $foo.queue().length, 0, "The animation queue was cleared" );
this.clock.tick( 100 );
- equal( nw, $foo.css( "width" ), "The animation didn't continue" );
+ assert.equal( nw, $foo.css( "width" ), "The animation didn't continue" );
} );
-test( "stop(clearQueue, gotoEnd)", function() {
- expect( 1 );
+QUnit.test( "stop(clearQueue, gotoEnd)", function( assert ) {
+ assert.expect( 1 );
var $foo = jQuery( "#foo" ),
w = 0,
@@ -728,7 +728,7 @@ test( "stop(clearQueue, gotoEnd)", function() {
$foo.animate( { width: "hide" }, 1000 );
this.clock.tick( 100 );
nw = $foo.css( "width" );
- ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px" );
+ assert.ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px" );
$foo.stop( false, true );
nw = $foo.css( "width" );
@@ -743,8 +743,8 @@ test( "stop(clearQueue, gotoEnd)", function() {
$foo.stop( true );
} );
-test( "stop( queue, ..., ... ) - Stop single queues", function() {
- expect( 3 );
+QUnit.test( "stop( queue, ..., ... ) - Stop single queues", function( assert ) {
+ assert.expect( 3 );
var saved,
foo = jQuery( "#foo" ).css( { width: 200, height: 200 } );
@@ -753,8 +753,8 @@ test( "stop( queue, ..., ... ) - Stop single queues", function() {
}, {
duration: 500,
complete: function() {
- equal( parseFloat( foo.css( "width" ) ), 400, "Animation completed for standard queue" );
- equal( parseFloat( foo.css( "height" ) ), saved, "Height was not changed after the second stop" );
+ assert.equal( parseFloat( foo.css( "width" ) ), 400, "Animation completed for standard queue" );
+ assert.equal( parseFloat( foo.css( "height" ) ), saved, "Height was not changed after the second stop" );
}
} );
@@ -765,7 +765,7 @@ test( "stop( queue, ..., ... ) - Stop single queues", function() {
queue: "height"
} ).dequeue( "height" ).stop( "height", false, true );
- equal( parseFloat( foo.css( "height" ) ), 400, "Height was stopped with gotoEnd" );
+ assert.equal( parseFloat( foo.css( "height" ) ), 400, "Height was stopped with gotoEnd" );
foo.animate( {
height: 200
@@ -777,25 +777,25 @@ test( "stop( queue, ..., ... ) - Stop single queues", function() {
this.clock.tick( 500 );
} );
-test( "toggle()", function() {
- expect( 6 );
+QUnit.test( "toggle()", function( assert ) {
+ assert.expect( 6 );
var x = jQuery( "#foo" );
- ok( x.is( ":visible" ), "is visible" );
+ assert.ok( x.is( ":visible" ), "is visible" );
x.toggle();
- ok( x.is( ":hidden" ), "is hidden" );
+ assert.ok( x.is( ":hidden" ), "is hidden" );
x.toggle();
- ok( x.is( ":visible" ), "is visible again" );
+ assert.ok( x.is( ":visible" ), "is visible again" );
x.toggle( true );
- ok( x.is( ":visible" ), "is visible" );
+ assert.ok( x.is( ":visible" ), "is visible" );
x.toggle( false );
- ok( x.is( ":hidden" ), "is hidden" );
+ assert.ok( x.is( ":hidden" ), "is hidden" );
x.toggle( true );
- ok( x.is( ":visible" ), "is visible again" );
+ assert.ok( x.is( ":visible" ), "is visible again" );
} );
-test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() {
- expect( 7 );
+QUnit.test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function( assert ) {
+ assert.expect( 7 );
var div = jQuery( "" ).appendTo( "#qunit-fixture" ).css( {
color: "#ABC",
@@ -804,13 +804,13 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() {
marginBottom: "-11000px"
} )[ 0 ];
- equal(
+ assert.equal(
( new jQuery.fx( div, {}, "color" ) ).cur(),
jQuery.css( div, "color" ),
"Return the same value as jQuery.css for complex properties (bug #7912)"
);
- strictEqual(
+ assert.strictEqual(
( new jQuery.fx( div, {}, "borderLeftWidth" ) ).cur(),
5,
"Return simple values parsed as Float"
@@ -822,12 +822,12 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() {
// value as it is being newed
jQuery.cssHooks.backgroundPosition = {
get: function() {
- ok( true, "hook used" );
+ assert.ok( true, "hook used" );
return "";
}
};
- strictEqual(
+ assert.strictEqual(
( new jQuery.fx( div, {}, "backgroundPosition" ) ).cur(),
0,
"Return 0 when jQuery.css returns an empty string"
@@ -835,13 +835,13 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() {
delete jQuery.cssHooks.backgroundPosition;
- strictEqual(
+ assert.strictEqual(
( new jQuery.fx( div, {}, "left" ) ).cur(),
0,
"Return 0 when jQuery.css returns 'auto'"
);
- equal(
+ assert.equal(
( new jQuery.fx( div, {}, "marginBottom" ) ).cur(),
-11000,
"support negative values < -10000 (bug #7193)"
@@ -850,8 +850,8 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() {
jQuery( div ).remove();
} );
-test( "Overflow and Display", function() {
- expect( 4 );
+QUnit.test( "Overflow and Display", function( assert ) {
+ assert.expect( 4 );
var
testClass = jQuery.makeTest( "Overflow and Display" )
@@ -859,8 +859,8 @@ test( "Overflow and Display", function() {
testStyle = jQuery.makeTest( "Overflow and Display (inline style)" )
.css( { overflow: "visible", display: "inline" } ),
done = function() {
- equal( jQuery.css( this, "overflow" ), "visible", "Overflow should be 'visible'" );
- equal( jQuery.css( this, "display" ), "inline", "Display should be 'inline'" );
+ assert.equal( jQuery.css( this, "overflow" ), "visible", "Overflow should be 'visible'" );
+ assert.equal( jQuery.css( this, "display" ), "inline", "Display should be 'inline'" );
};
testClass.add( testStyle )
@@ -929,7 +929,7 @@ jQuery.each( {
return 0;
}
}, function( tn, t ) {
- test( fn + " to " + tn, function() {
+ QUnit.test( fn + " to " + tn, function( assert ) {
var num, anim,
elem = jQuery.makeTest( fn + " to " + tn ),
t_w = t( elem, "width" ),
@@ -956,7 +956,7 @@ jQuery.each( {
if ( t_w.constructor === Number ) { num += 2; }
if ( t_h.constructor === Number ) { num += 2; }
- expect( num );
+ assert.expect( num );
anim = { width: t_w, height: t_h, opacity: t_o };
@@ -967,16 +967,16 @@ jQuery.each( {
elem = $elem[ 0 ];
if ( t_w === "show" ) {
- equal( $elem.css( "display" ), "block",
+ assert.equal( $elem.css( "display" ), "block",
"Showing, display should block: " + elem.style.display );
}
if ( t_w === "hide" || t_w === "show" ) {
- ok( f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf( f_w ) === 0, "Width must be reset to " + f_w + ": " + elem.style.width );
+ assert.ok( f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf( f_w ) === 0, "Width must be reset to " + f_w + ": " + elem.style.width );
}
if ( t_h === "hide" || t_h === "show" ) {
- ok( f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf( f_h ) === 0, "Height must be reset to " + f_h + ": " + elem.style.height );
+ assert.ok( f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf( f_h ) === 0, "Height must be reset to " + f_h + ": " + elem.style.height );
}
cur_o = jQuery.style( elem, "opacity" );
@@ -997,33 +997,33 @@ jQuery.each( {
}
if ( t_o === "hide" || t_o === "show" ) {
- equal( cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o );
+ assert.equal( cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o );
}
if ( t_w === "hide" ) {
- equal( elem.style.display, "none", "Hiding, display should be none: " + elem.style.display );
+ assert.equal( elem.style.display, "none", "Hiding, display should be none: " + elem.style.display );
}
if ( t_o.constructor === Number ) {
- equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o );
+ assert.equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o );
- ok( jQuery.css( elem, "opacity" ) !== "" || cur_o === t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o );
+ assert.ok( jQuery.css( elem, "opacity" ) !== "" || cur_o === t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o );
}
if ( t_w.constructor === Number ) {
- equal( elem.style.width, t_w + "px", "Final width should be " + t_w + ": " + elem.style.width );
+ assert.equal( elem.style.width, t_w + "px", "Final width should be " + t_w + ": " + elem.style.width );
cur_w = jQuery.css( elem, "width" );
- ok( elem.style.width !== "" || cur_w === t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w );
+ assert.ok( elem.style.width !== "" || cur_w === t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w );
}
if ( t_h.constructor === Number ) {
- equal( elem.style.height, t_h + "px", "Final height should be " + t_h + ": " + elem.style.height );
+ assert.equal( elem.style.height, t_h + "px", "Final height should be " + t_h + ": " + elem.style.height );
cur_h = jQuery.css( elem, "height" );
- ok( elem.style.height !== "" || cur_h === t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h );
+ assert.ok( elem.style.height !== "" || cur_h === t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h );
}
if ( t_h === "show" ) {
@@ -1031,9 +1031,9 @@ jQuery.each( {
jQuery( elem ).append( " Some more text and some more..." );
if ( /Auto/.test( fn ) ) {
- notEqual( jQuery.css( elem, "height" ), old_h, "Make sure height is auto." );
+ assert.notEqual( jQuery.css( elem, "height" ), old_h, "Make sure height is auto." );
} else {
- equal( jQuery.css( elem, "height" ), old_h, "Make sure height is not auto." );
+ assert.equal( jQuery.css( elem, "height" ), old_h, "Make sure height is not auto." );
}
}
@@ -1046,19 +1046,19 @@ jQuery.each( {
} );
} );
-test( "Effects chaining", function() {
+QUnit.test( "Effects chaining", function( assert ) {
var remaining = 16,
props = [ "opacity", "height", "width", "display", "overflow" ],
setup = function( name, selector ) {
var $el = jQuery( selector );
return $el.data( getProps( $el[ 0 ] ) ).data( "name", name );
},
- assert = function() {
+ check = function() {
var data = jQuery.data( this ),
name = data.name;
delete data.name;
- deepEqual( getProps( this ), data, name );
+ assert.deepEqual( getProps( this ), data, name );
jQuery.removeData( this );
},
@@ -1070,24 +1070,24 @@ test( "Effects chaining", function() {
return obj;
};
- expect( remaining );
+ assert.expect( remaining );
- setup( ".fadeOut().fadeIn()", "#fadein div" ).fadeOut( "fast" ).fadeIn( "fast", assert );
- setup( ".fadeIn().fadeOut()", "#fadeout div" ).fadeIn( "fast" ).fadeOut( "fast", assert );
- setup( ".hide().show()", "#show div" ).hide( "fast" ).show( "fast", assert );
- setup( ".show().hide()", "#hide div" ).show( "fast" ).hide( "fast", assert );
- setup( ".show().hide(easing)", "#easehide div" ).show( "fast" ).hide( "fast", "linear", assert );
- setup( ".toggle().toggle() - in", "#togglein div" ).toggle( "fast" ).toggle( "fast", assert );
- setup( ".toggle().toggle() - out", "#toggleout div" ).toggle( "fast" ).toggle( "fast", assert );
- setup( ".toggle().toggle(easing) - out", "#easetoggleout div" ).toggle( "fast" ).toggle( "fast", "linear", assert );
- setup( ".slideDown().slideUp()", "#slidedown div" ).slideDown( "fast" ).slideUp( "fast", assert );
- setup( ".slideUp().slideDown()", "#slideup div" ).slideUp( "fast" ).slideDown( "fast", assert );
- setup( ".slideUp().slideDown(easing)", "#easeslideup div" ).slideUp( "fast" ).slideDown( "fast", "linear", assert );
- setup( ".slideToggle().slideToggle() - in", "#slidetogglein div" ).slideToggle( "fast" ).slideToggle( "fast", assert );
- setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div" ).slideToggle( "fast" ).slideToggle( "fast", assert );
- setup( ".fadeToggle().fadeToggle() - in", "#fadetogglein div" ).fadeToggle( "fast" ).fadeToggle( "fast", assert );
- setup( ".fadeToggle().fadeToggle() - out", "#fadetoggleout div" ).fadeToggle( "fast" ).fadeToggle( "fast", assert );
- setup( ".fadeTo(0.5).fadeTo(1.0, easing)", "#fadeto div" ).fadeTo( "fast", 0.5 ).fadeTo( "fast", 1.0, "linear", assert );
+ setup( ".fadeOut().fadeIn()", "#fadein div" ).fadeOut( "fast" ).fadeIn( "fast", check );
+ setup( ".fadeIn().fadeOut()", "#fadeout div" ).fadeIn( "fast" ).fadeOut( "fast", check );
+ setup( ".hide().show()", "#show div" ).hide( "fast" ).show( "fast", check );
+ setup( ".show().hide()", "#hide div" ).show( "fast" ).hide( "fast", check );
+ setup( ".show().hide(easing)", "#easehide div" ).show( "fast" ).hide( "fast", "linear", check );
+ setup( ".toggle().toggle() - in", "#togglein div" ).toggle( "fast" ).toggle( "fast", check );
+ setup( ".toggle().toggle() - out", "#toggleout div" ).toggle( "fast" ).toggle( "fast", check );
+ setup( ".toggle().toggle(easing) - out", "#easetoggleout div" ).toggle( "fast" ).toggle( "fast", "linear", check );
+ setup( ".slideDown().slideUp()", "#slidedown div" ).slideDown( "fast" ).slideUp( "fast", check );
+ setup( ".slideUp().slideDown()", "#slideup div" ).slideUp( "fast" ).slideDown( "fast", check );
+ setup( ".slideUp().slideDown(easing)", "#easeslideup div" ).slideUp( "fast" ).slideDown( "fast", "linear", check );
+ setup( ".slideToggle().slideToggle() - in", "#slidetogglein div" ).slideToggle( "fast" ).slideToggle( "fast", check );
+ setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div" ).slideToggle( "fast" ).slideToggle( "fast", check );
+ setup( ".fadeToggle().fadeToggle() - in", "#fadetogglein div" ).fadeToggle( "fast" ).fadeToggle( "fast", check );
+ setup( ".fadeToggle().fadeToggle() - out", "#fadetoggleout div" ).fadeToggle( "fast" ).fadeToggle( "fast", check );
+ setup( ".fadeTo(0.5).fadeTo(1.0, easing)", "#fadeto div" ).fadeTo( "fast", 0.5 ).fadeTo( "fast", 1.0, "linear", check );
this.clock.tick( 400 );
} );
@@ -1106,21 +1106,21 @@ jQuery.makeTest = function( text ) {
jQuery.makeTest.id = 1;
-test( "jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function() {
- expect( 4 );
+QUnit.test( "jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function( assert ) {
+ assert.expect( 4 );
var $checkedtest = jQuery( "#checkedtest" );
$checkedtest.hide().show( "fast", function() {
- ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." );
- ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." );
- ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." );
- ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." );
+ assert.ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." );
+ assert.ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." );
+ assert.ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." );
+ assert.ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." );
} );
this.clock.tick( 200 );
} );
-test( "interrupt toggle", function() {
- expect( 24 );
+QUnit.test( "interrupt toggle", function( assert ) {
+ assert.expect( 24 );
var env = this,
longDuration = 2000,
@@ -1148,7 +1148,7 @@ test( "interrupt toggle", function() {
$methodElems[ method ]( longDuration );
setTimeout( function() {
$methodElems.stop().each( function() {
- notEqual( jQuery( this ).css( prop ), jQuery.data( this, "startVal" ), ".stop() before completion of hiding ." + method + "() - #" + this.id );
+ assert.notEqual( jQuery( this ).css( prop ), jQuery.data( this, "startVal" ), ".stop() before completion of hiding ." + method + "() - #" + this.id );
} );
// Restore
@@ -1159,17 +1159,17 @@ test( "interrupt toggle", function() {
$elem.removeData( "startVal" );
- equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
+ assert.equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
// Interrupt a showing toggle
$elem.hide()[ method ]( longDuration );
setTimeout( function() {
$elem.stop();
- notEqual( $elem.css( prop ), startVal, ".stop() before completion of showing ." + method + "() - #" + id );
+ assert.notEqual( $elem.css( prop ), startVal, ".stop() before completion of showing ." + method + "() - #" + id );
// Restore
$elem[ method ]( shortDuration, function() {
- equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
+ assert.equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
finish();
} );
}, shortDuration );
@@ -1181,9 +1181,9 @@ test( "interrupt toggle", function() {
// FIXME untangle the set timeouts
} );
-test( "animate with per-property easing", function() {
+QUnit.test( "animate with per-property easing", function( assert ) {
- expect( 5 );
+ assert.expect( 5 );
var data = { a: 0, b: 0, c: 0 },
test1Called = false,
@@ -1211,18 +1211,18 @@ test( "animate with per-property easing", function() {
};
jQuery( data ).animate( props, 400, "_defaultTest", function() {
- ok( test1Called, "Easing function (_test1) called" );
- ok( test2Called, "Easing function (_test2) called" );
- ok( defaultTestCalled, "Easing function (_default) called" );
- equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)" );
- equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)" );
+ assert.ok( test1Called, "Easing function (_test1) called" );
+ assert.ok( test2Called, "Easing function (_test2) called" );
+ assert.ok( defaultTestCalled, "Easing function (_default) called" );
+ assert.equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)" );
+ assert.equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)" );
} );
this.clock.tick( 400 );
} );
-test( "animate with CSS shorthand properties", function() {
- expect( 11 );
+QUnit.test( "animate with CSS shorthand properties", function( assert ) {
+ assert.expect( 11 );
var easeAnimation_count = 0,
easeProperty_count = 0,
@@ -1245,20 +1245,20 @@ test( "animate with CSS shorthand properties", function() {
jQuery( "#foo" )
.animate( propsBasic, 200, "animationScope", function() {
- equal( this.style.paddingTop, "10px", "padding-top was animated" );
- equal( this.style.paddingLeft, "20px", "padding-left was animated" );
- equal( this.style.paddingRight, "20px", "padding-right was animated" );
- equal( this.style.paddingBottom, "30px", "padding-bottom was animated" );
- equal( easeAnimation_count, 4, "per-animation default easing called for each property" );
+ assert.equal( this.style.paddingTop, "10px", "padding-top was animated" );
+ assert.equal( this.style.paddingLeft, "20px", "padding-left was animated" );
+ assert.equal( this.style.paddingRight, "20px", "padding-right was animated" );
+ assert.equal( this.style.paddingBottom, "30px", "padding-bottom was animated" );
+ assert.equal( easeAnimation_count, 4, "per-animation default easing called for each property" );
easeAnimation_count = 0;
} )
.animate( propsSpecial, 200, "animationScope", function() {
- equal( this.style.paddingTop, "1px", "padding-top was animated again" );
- equal( this.style.paddingLeft, "2px", "padding-left was animated again" );
- equal( this.style.paddingRight, "2px", "padding-right was animated again" );
- equal( this.style.paddingBottom, "3px", "padding-bottom was animated again" );
- equal( easeAnimation_count, 0, "per-animation default easing not called" );
- equal( easeProperty_count, 4, "special easing called for each property" );
+ assert.equal( this.style.paddingTop, "1px", "padding-top was animated again" );
+ assert.equal( this.style.paddingLeft, "2px", "padding-left was animated again" );
+ assert.equal( this.style.paddingRight, "2px", "padding-right was animated again" );
+ assert.equal( this.style.paddingBottom, "3px", "padding-bottom was animated again" );
+ assert.equal( easeAnimation_count, 0, "per-animation default easing not called" );
+ assert.equal( easeProperty_count, 4, "special easing called for each property" );
jQuery( this ).css( "padding", "0" );
delete jQuery.easing.animationScope;
@@ -1267,43 +1267,43 @@ test( "animate with CSS shorthand properties", function() {
this.clock.tick( 400 );
} );
-test( "hide hidden elements, with animation (bug #7141)", function() {
- expect( 3 );
+QUnit.test( "hide hidden elements, with animation (bug #7141)", function( assert ) {
+ assert.expect( 3 );
var div = jQuery( "" ).appendTo( "#qunit-fixture" );
- equal( div.css( "display" ), "none", "Element is hidden by default" );
+ assert.equal( div.css( "display" ), "none", "Element is hidden by default" );
div.hide( 1, function() {
- ok( !jQuery._data( div, "display" ), "display data is undefined after hiding an already-hidden element" );
+ assert.ok( !jQuery._data( div, "display" ), "display data is undefined after hiding an already-hidden element" );
div.show( 1, function() {
- equal( div.css( "display" ), "block", "Show a double-hidden element" );
+ assert.equal( div.css( "display" ), "block", "Show a double-hidden element" );
} );
} );
this.clock.tick( 10 );
} );
-test( "animate unit-less properties (#4966)", function() {
- expect( 2 );
+QUnit.test( "animate unit-less properties (#4966)", function( assert ) {
+ assert.expect( 2 );
var div = jQuery( "" ).appendTo( "#qunit-fixture" );
- equal( div.css( "z-index" ), "0", "z-index is 0" );
+ assert.equal( div.css( "z-index" ), "0", "z-index is 0" );
div.animate( { zIndex: 2 }, function() {
- equal( div.css( "z-index" ), "2", "z-index is 2" );
+ assert.equal( div.css( "z-index" ), "2", "z-index is 2" );
} );
this.clock.tick( 400 );
} );
-test( "animate properties missing px w/ opacity as last (#9074)", function() {
- expect( 2 );
+QUnit.test( "animate properties missing px w/ opacity as last (#9074)", function( assert ) {
+ assert.expect( 2 );
- expect( 6 );
+ assert.expect( 6 );
var ml, l,
div = jQuery( "" )
.appendTo( "#qunit-fixture" );
function cssInt( prop ) {
return parseInt( div.css( prop ), 10 );
}
- equal( cssInt( "marginLeft" ), 0, "Margin left is 0" );
- equal( cssInt( "left" ), 0, "Left is 0" );
+ assert.equal( cssInt( "marginLeft" ), 0, "Margin left is 0" );
+ assert.equal( cssInt( "left" ), 0, "Left is 0" );
div.animate( {
left: 200,
marginLeft: 200,
@@ -1314,15 +1314,15 @@ test( "animate properties missing px w/ opacity as last (#9074)", function() {
ml = cssInt( "marginLeft" );
l = cssInt( "left" );
- notEqual( ml, 0, "Margin left is not 0 after partial animate" );
- notEqual( ml, 200, "Margin left is not 200 after partial animate" );
- notEqual( l, 0, "Left is not 0 after partial animate" );
- notEqual( l, 200, "Left is not 200 after partial animate" );
+ assert.notEqual( ml, 0, "Margin left is not 0 after partial animate" );
+ assert.notEqual( ml, 200, "Margin left is not 200 after partial animate" );
+ assert.notEqual( l, 0, "Left is not 0 after partial animate" );
+ assert.notEqual( l, 200, "Left is not 200 after partial animate" );
div.stop().remove();
} );
-test( "callbacks should fire in correct order (#9100)", function() {
- expect( 1 );
+QUnit.test( "callbacks should fire in correct order (#9100)", function( assert ) {
+ assert.expect( 1 );
var a = 1,
cb = 0;
@@ -1335,14 +1335,14 @@ test( "callbacks should fire in correct order (#9100)", function() {
a *= jQuery( this ).data( "operation" ) === "*2" ? 2 : a;
cb++;
if ( cb === 2 ) {
- equal( a, 4, "test value has been *2 and _then_ ^2" );
+ assert.equal( a, 4, "test value has been *2 and _then_ ^2" );
}
} );
this.clock.tick( 20 );
} );
-test( "callbacks that throw exceptions will be removed (#5684)", function() {
- expect( 2 );
+QUnit.test( "callbacks that throw exceptions will be removed (#5684)", function( assert ) {
+ assert.expect( 2 );
var foo = jQuery( "#foo" );
@@ -1360,30 +1360,30 @@ test( "callbacks that throw exceptions will be removed (#5684)", function() {
jQuery.fx.stop();
this.clock.tick( 1 );
- throws( jQuery.fx.tick, TestException, "Exception was thrown" );
+ assert.throws( jQuery.fx.tick, TestException, "Exception was thrown" );
// the second call shouldn't
jQuery.fx.tick();
- ok( true, "Test completed without throwing a second exception" );
+ assert.ok( true, "Test completed without throwing a second exception" );
} );
-test( "animate will scale margin properties individually", function() {
- expect( 2 );
+QUnit.test( "animate will scale margin properties individually", function( assert ) {
+ assert.expect( 2 );
var foo = jQuery( "#foo" ).css( {
"margin": 0,
"marginLeft": 100
} );
- ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "Sanity Check" );
+ assert.ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "Sanity Check" );
foo.animate( {
"margin": 200
} ).stop();
- ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "The margin properties are different" );
+ assert.ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "The margin properties are different" );
// clean up for next test
foo.css( {
@@ -1394,8 +1394,8 @@ test( "animate will scale margin properties individually", function() {
} );
} );
-test( "Do not append px to 'fill-opacity' #9548", function() {
- expect( 1 );
+QUnit.test( "Do not append px to 'fill-opacity' #9548", function( assert ) {
+ assert.expect( 1 );
var $div = jQuery( "
" ).appendTo( "#qunit-fixture" );
@@ -1403,16 +1403,16 @@ test( "Do not append px to 'fill-opacity' #9548", function() {
// Support: Android 2.3 (no support for fill-opacity)
if ( jQuery( this ).css( "fill-opacity" ) ) {
- equal( jQuery( this ).css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
+ assert.equal( jQuery( this ).css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" );
} else {
- ok( true, "No support for fill-opacity CSS property" );
+ assert.ok( true, "No support for fill-opacity CSS property" );
}
$div.remove();
} );
} );
-test( "line-height animates correctly (#13855)", function() {
- expect( 12 );
+QUnit.test( "line-height animates correctly (#13855)", function( assert ) {
+ assert.expect( 12 );
var t0,
clock = this.clock,
@@ -1443,9 +1443,9 @@ test( "line-height animates correctly (#13855)", function() {
initial = initialHeight[ i ],
height = jQuery( this ).height(),
lower = initial * ( 1 - progress ) / tolerance;
- ok( height < initial, "hide " + label + ": upper bound; " +
+ assert.ok( height < initial, "hide " + label + ": upper bound; " +
height + " < " + initial + " @ " + ( progress * 100 ) + "%" );
- ok( height > lower, "hide " + label + ": lower bound; " +
+ assert.ok( height > lower, "hide " + label + ": lower bound; " +
height + " > " + lower + " @ " + ( progress * 100 ) + "%" );
} );
@@ -1461,7 +1461,7 @@ test( "line-height animates correctly (#13855)", function() {
initial = initialHeight[ i ],
height = jQuery( this ).height(),
upper = initial * progress * tolerance;
- ok( height < upper, "show " + label + ": upper bound; " +
+ assert.ok( height < upper, "show " + label + ": upper bound; " +
height + " < " + upper + " @ " + ( progress * 100 ) + "%" );
} );
@@ -1475,8 +1475,8 @@ clock.tick( 50 );
} );
// Start 1.8 Animation tests
-test( "jQuery.Animation( object, props, opts )", function() {
- expect( 4 );
+QUnit.test( "jQuery.Animation( object, props, opts )", function( assert ) {
+ assert.expect( 4 );
var animation,
testObject = {
@@ -1493,17 +1493,17 @@ test( "jQuery.Animation( object, props, opts )", function() {
animation = jQuery.Animation( testObject, testDest, { "duration": 1 } );
animation.done( function() {
for ( var prop in testDest ) {
- equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop );
+ assert.equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop );
}
animation.done( function() {
- deepEqual( testObject, testDest, "No unexpected properties" );
+ assert.deepEqual( testObject, testDest, "No unexpected properties" );
} );
} );
this.clock.tick( 10 );
} );
-test( "Animate Option: step: function( percent, tween )", function() {
- expect( 1 );
+QUnit.test( "Animate Option: step: function( percent, tween )", function( assert ) {
+ assert.expect( 1 );
var counter = {};
jQuery( "#foo" ).animate( {
@@ -1520,7 +1520,7 @@ test( "Animate Option: step: function( percent, tween )", function() {
calls[ value === 0 ? 0 : 1 ] = value;
}
} ).queue( function( next ) {
- deepEqual( counter, {
+ assert.deepEqual( counter, {
prop1: [ 0, 1 ],
prop2: [ 0, 2 ],
prop3: [ 0, 3 ]
@@ -1530,41 +1530,41 @@ test( "Animate Option: step: function( percent, tween )", function() {
this.clock.tick( 10 );
} );
-test( "Animate callbacks have correct context", function() {
- expect( 2 );
+QUnit.test( "Animate callbacks have correct context", function( assert ) {
+ assert.expect( 2 );
var foo = jQuery( "#foo" );
foo.animate( {
height: 10
}, 10, function() {
- equal( foo[ 0 ], this, "Complete callback after stop(true) `this` is element" );
+ assert.equal( foo[ 0 ], this, "Complete callback after stop(true) `this` is element" );
} ).stop( true, true );
foo.animate( {
height: 100
}, 10, function() {
- equal( foo[ 0 ], this, "Complete callback `this` is element" );
+ assert.equal( foo[ 0 ], this, "Complete callback `this` is element" );
} );
this.clock.tick( 10 );
} );
-test( "User supplied callback called after show when fx off (#8892)", function() {
- expect( 2 );
+QUnit.test( "User supplied callback called after show when fx off (#8892)", function( assert ) {
+ assert.expect( 2 );
var foo = jQuery( "#foo" );
jQuery.fx.off = true;
foo.hide();
foo.fadeIn( 500, function() {
- ok( jQuery( this ).is( ":visible" ), "Element is visible in callback" );
+ assert.ok( jQuery( this ).is( ":visible" ), "Element is visible in callback" );
foo.fadeOut( 500, function() {
- ok( jQuery( this ).is( ":hidden" ), "Element is hidden in callback" );
+ assert.ok( jQuery( this ).is( ":hidden" ), "Element is hidden in callback" );
jQuery.fx.off = false;
} );
} );
this.clock.tick( 1000 );
} );
-test( "animate should set display for disconnected nodes", function() {
- expect( 20 );
+QUnit.test( "animate should set display for disconnected nodes", function( assert ) {
+ assert.expect( 20 );
var methods = {
toggle: [ 1 ],
@@ -1583,47 +1583,47 @@ test( "animate should set display for disconnected nodes", function() {
underFragmentDisplay = $divTest.css( "display" ),
clock = this.clock;
- strictEqual( $divEmpty[ 0 ].parentNode, null, "Setup: element with null parentNode" );
- strictEqual( ( $divTest[ 0 ].parentNode || {} ).nodeType, 11, "Setup: element under fragment" );
+ assert.strictEqual( $divEmpty[ 0 ].parentNode, null, "Setup: element with null parentNode" );
+ assert.strictEqual( ( $divTest[ 0 ].parentNode || {} ).nodeType, 11, "Setup: element under fragment" );
- strictEqual( $divEmpty.show()[ 0 ].style.display, "",
+ assert.strictEqual( $divEmpty.show()[ 0 ].style.display, "",
"set display with show() for element with null parentNode" );
- strictEqual( $divTest.show()[ 0 ].style.display, "",
+ assert.strictEqual( $divTest.show()[ 0 ].style.display, "",
"set display with show() for element under fragment" );
- strictEqual( $divNone.show()[ 0 ].style.display, "",
+ assert.strictEqual( $divNone.show()[ 0 ].style.display, "",
"show() should change display if it already set to none" );
- strictEqual( $divInline.show()[ 0 ].style.display, "inline",
+ assert.strictEqual( $divInline.show()[ 0 ].style.display, "inline",
"show() should not change display if it already set" );
jQuery.each( methods, function( name, opt ) {
jQuery.fn[ name ].apply( jQuery( "" ), opt.concat( [ function() {
- strictEqual( jQuery( this ).css( "display" ), nullParentDisplay,
+ assert.strictEqual( jQuery( this ).css( "display" ), nullParentDisplay,
"." + name + " block with null parentNode" );
} ] ) );
jQuery.fn[ name ].apply( jQuery( "
test
" ), opt.concat( [ function() {
- strictEqual( jQuery( this ).css( "display" ), underFragmentDisplay,
+ assert.strictEqual( jQuery( this ).css( "display" ), underFragmentDisplay,
"." + name + " block under fragment" );
} ] ) );
} );
clock.tick( 400 );
} );
-test( "Animation callback should not show animated element as :animated (#7157)", function() {
- expect( 1 );
+QUnit.test( "Animation callback should not show animated element as :animated (#7157)", function( assert ) {
+ assert.expect( 1 );
var foo = jQuery( "#foo" );
foo.animate( {
opacity: 0
}, 100, function() {
- ok( !foo.is( ":animated" ), "The element is not animated" );
+ assert.ok( !foo.is( ":animated" ), "The element is not animated" );
} );
this.clock.tick( 100 );
} );
-test( "Initial step callback should show element as :animated (#14623)", function() {
- expect( 1 );
+QUnit.test( "Initial step callback should show element as :animated (#14623)", function( assert ) {
+ assert.expect( 1 );
var foo = jQuery( "#foo" );
@@ -1632,15 +1632,15 @@ test( "Initial step callback should show element as :animated (#14623)", functio
}, {
duration: 100,
step: function() {
- ok( foo.is( ":animated" ), "The element matches :animated inside step function" );
+ assert.ok( foo.is( ":animated" ), "The element matches :animated inside step function" );
}
} );
this.clock.tick( 1 );
foo.stop();
} );
-test( "hide called on element within hidden parent should set display to none (#10045)", function() {
- expect( 3 );
+QUnit.test( "hide called on element within hidden parent should set display to none (#10045)", function( assert ) {
+ assert.expect( 3 );
var hidden = jQuery( ".hidden" ),
elems = jQuery( "
hide
hide0
hide1
" );
@@ -1652,17 +1652,17 @@ test( "hide called on element within hidden parent should set display to none (#
elems.eq( 1 ).hide( 0 ),
elems.eq( 2 ).hide( 1 )
).done( function() {
- strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element within hidden parent should set display to none" );
- strictEqual( elems.get( 1 ).style.display, "none", "hide( 0 ) called on element within hidden parent should set display to none" );
- strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element within hidden parent should set display to none" );
+ assert.strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element within hidden parent should set display to none" );
+ assert.strictEqual( elems.get( 1 ).style.display, "none", "hide( 0 ) called on element within hidden parent should set display to none" );
+ assert.strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element within hidden parent should set display to none" );
elems.remove();
} );
this.clock.tick( 10 );
} );
-test( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", function() {
- expect( 5 );
+QUnit.test( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", function( assert ) {
+ assert.expect( 5 );
var foo = jQuery( "#foo" ),
i = 0,
@@ -1681,34 +1681,34 @@ test( "hide, fadeOut and slideUp called on element width height and width = 0 sh
elems.eq( 3 ).fadeOut(),
elems.eq( 4 ).slideUp()
).done( function() {
- strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element width height and width = 0 should set display to none" );
- strictEqual( elems.get( 1 ).style.display, "none",
+ assert.strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element width height and width = 0 should set display to none" );
+ assert.strictEqual( elems.get( 1 ).style.display, "none",
"hide( jQuery.noop ) called on element width height and width = 0 should set display to none" );
- strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element width height and width = 0 should set display to none" );
- strictEqual( elems.get( 3 ).style.display, "none", "fadeOut() called on element width height and width = 0 should set display to none" );
- strictEqual( elems.get( 4 ).style.display, "none", "slideUp() called on element width height and width = 0 should set display to none" );
+ assert.strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element width height and width = 0 should set display to none" );
+ assert.strictEqual( elems.get( 3 ).style.display, "none", "fadeOut() called on element width height and width = 0 should set display to none" );
+ assert.strictEqual( elems.get( 4 ).style.display, "none", "slideUp() called on element width height and width = 0 should set display to none" );
} );
this.clock.tick( 400 );
} );
-test( "hide should not leave hidden inline elements visible (#14848)", function() {
- expect( 2 );
+QUnit.test( "hide should not leave hidden inline elements visible (#14848)", function( assert ) {
+ assert.expect( 2 );
var el = jQuery( "#simon1" );
el.hide( 1, function() {
- equal( el.css( "display" ), "none", "hidden" );
+ assert.equal( el.css( "display" ), "none", "hidden" );
el.hide( 1, function() {
- equal( el.css( "display" ), "none", "still hidden" );
+ assert.equal( el.css( "display" ), "none", "still hidden" );
} );
} );
this.clock.tick( 100 );
} );
-test( "Handle queue:false promises", function() {
- expect( 10 );
+QUnit.test( "Handle queue:false promises", function( assert ) {
+ assert.expect( 10 );
var foo = jQuery( "#foo" ).clone().addBack(),
step = 1;
@@ -1719,14 +1719,14 @@ test( "Handle queue:false promises", function() {
duration: 10,
queue: false,
complete: function() {
- ok( step++ <= 2, "Step one or two" );
+ assert.ok( step++ <= 2, "Step one or two" );
}
} ).animate( {
bottom: 1
}, {
duration: 10,
complete: function() {
- ok( step > 2 && step < 5, "Step three or four" );
+ assert.ok( step > 2 && step < 5, "Step three or four" );
step++;
}
} );
@@ -1734,13 +1734,13 @@ test( "Handle queue:false promises", function() {
this.clock.tick( 10 );
foo.promise().done( function() {
- equal( step++, 5, "steps 1-5: queue:false then queue:fx done" );
+ assert.equal( step++, 5, "steps 1-5: queue:false then queue:fx done" );
foo.animate( {
top: 10
}, {
duration: 10,
complete: function() {
- ok( step > 5 && step < 8, "Step six or seven" );
+ assert.ok( step > 5 && step < 8, "Step six or seven" );
step++;
}
} ).animate( {
@@ -1749,19 +1749,19 @@ test( "Handle queue:false promises", function() {
duration: 10,
queue: false,
complete: function() {
- ok( step > 7 && step < 10, "Step eight or nine" );
+ assert.ok( step > 7 && step < 10, "Step eight or nine" );
step++;
}
} ).promise().done( function() {
- equal( step++, 10, "steps 6-10: queue:fx then queue:false" );
+ assert.equal( step++, 10, "steps 6-10: queue:fx then queue:false" );
} );
} );
this.clock.tick( 10 );
} );
-test( "multiple unqueued and promise", function() {
- expect( 4 );
+QUnit.test( "multiple unqueued and promise", function( assert ) {
+ assert.expect( 4 );
var foo = jQuery( "#foo" ),
step = 1;
@@ -1771,7 +1771,7 @@ test( "multiple unqueued and promise", function() {
duration: 500,
queue: false,
complete: function() {
- strictEqual( step++, 2, "Step 2" );
+ assert.strictEqual( step++, 2, "Step 2" );
}
} ).animate( {
top: 100
@@ -1779,7 +1779,7 @@ test( "multiple unqueued and promise", function() {
duration: 1000,
queue: false,
complete: function() {
- strictEqual( step++, 3, "Step 3" );
+ assert.strictEqual( step++, 3, "Step 3" );
}
} ).animate( {}, {
duration: 2000,
@@ -1787,16 +1787,16 @@ test( "multiple unqueued and promise", function() {
complete: function() {
// no properties is a non-op and finishes immediately
- strictEqual( step++, 1, "Step 1" );
+ assert.strictEqual( step++, 1, "Step 1" );
}
} ).promise().done( function() {
- strictEqual( step++, 4, "Step 4" );
+ assert.strictEqual( step++, 4, "Step 4" );
} );
this.clock.tick( 1000 );
} );
-test( "animate does not change start value for non-px animation (#7109)", function() {
- expect( 1 );
+QUnit.test( "animate does not change start value for non-px animation (#7109)", function( assert ) {
+ assert.expect( 1 );
var parent = jQuery( "
";
div = jQuery( markup );
div.children().remove( "span:nth-child(2n)" );
- equal( div.text(), "13", "relative selector in remove" );
+ assert.equal( div.text(), "13", "relative selector in remove" );
div = jQuery( markup );
div.children().remove( "span:first" );
- equal( div.text(), "234", "positional selector in remove" );
+ assert.equal( div.text(), "234", "positional selector in remove" );
div = jQuery( markup );
div.children().remove( "span:last" );
- equal( div.text(), "123", "positional selector in remove" );
+ assert.equal( div.text(), "123", "positional selector in remove" );
// using contents will get comments regular, text, and comment nodes
// Handle the case where no comment is in the document
- ok( jQuery( "#nonnodes" ).contents().length >= 2, "Check node,textnode,comment remove works" );
+ assert.ok( jQuery( "#nonnodes" ).contents().length >= 2, "Check node,textnode,comment remove works" );
jQuery( "#nonnodes" ).contents().remove();
- equal( jQuery( "#nonnodes" ).contents().length, 0, "Check node,textnode,comment remove works" );
+ assert.equal( jQuery( "#nonnodes" ).contents().length, 0, "Check node,textnode,comment remove works" );
} );
-test( "remove() event cleaning ", function() {
- expect( 1 );
+QUnit.test( "remove() event cleaning ", function( assert ) {
+ assert.expect( 1 );
var count, first, cleanUp;
@@ -1947,14 +1947,14 @@ test( "remove() event cleaning ", function() {
count++;
} ).remove().appendTo( "#qunit-fixture" ).trigger( "click" );
- strictEqual( 0, count, "Event handler has been removed" );
+ assert.strictEqual( 0, count, "Event handler has been removed" );
// Clean up detached data
cleanUp.remove();
} );
-test( "remove() in document order #13779", function() {
- expect( 1 );
+QUnit.test( "remove() in document order #13779", function( assert ) {
+ assert.expect( 1 );
var last,
cleanData = jQuery.cleanData;
@@ -1974,61 +1974,61 @@ test( "remove() in document order #13779", function() {
jQuery( ".removal-fixture" ).remove();
- equal( last, 3, "The removal fixtures were removed in document order" );
+ assert.equal( last, 3, "The removal fixtures were removed in document order" );
jQuery.cleanData = cleanData;
} );
-test( "detach() no filters", function() {
+QUnit.test( "detach() no filters", function( assert ) {
- expect( 3 );
+ assert.expect( 3 );
var first = jQuery( "#ap" ).children().first();
first.data( "foo", "bar" );
jQuery( "#ap" ).children().detach();
- ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" );
- equal( jQuery( "#ap" ).children().length, 0, "Check remove" );
+ assert.ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" );
+ assert.equal( jQuery( "#ap" ).children().length, 0, "Check remove" );
- equal( first.data( "foo" ), "bar" );
+ assert.equal( first.data( "foo" ), "bar" );
first.remove();
} );
-test( "detach() with filters", function() {
+QUnit.test( "detach() with filters", function( assert ) {
- expect( 8 );
+ assert.expect( 8 );
var markup, div;
jQuery( "#ap" ).children().detach( "a" );
- ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" );
- equal( jQuery( "#ap" ).children().length, 1, "Check filtered remove" );
+ assert.ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" );
+ assert.equal( jQuery( "#ap" ).children().length, 1, "Check filtered remove" );
jQuery( "#ap" ).children().detach( "a, code" );
- equal( jQuery( "#ap" ).children().length, 0, "Check multi-filtered remove" );
+ assert.equal( jQuery( "#ap" ).children().length, 0, "Check multi-filtered remove" );
// Positional and relative selectors
markup = "
1234
";
div = jQuery( markup );
div.children().detach( "span:nth-child(2n)" );
- equal( div.text(), "13", "relative selector in detach" );
+ assert.equal( div.text(), "13", "relative selector in detach" );
div = jQuery( markup );
div.children().detach( "span:first" );
- equal( div.text(), "234", "positional selector in detach" );
+ assert.equal( div.text(), "234", "positional selector in detach" );
div = jQuery( markup );
div.children().detach( "span:last" );
- equal( div.text(), "123", "positional selector in detach" );
+ assert.equal( div.text(), "123", "positional selector in detach" );
// using contents will get comments regular, text, and comment nodes
// Handle the case where no comment is in the document
- ok( jQuery( "#nonnodes" ).contents().length >= 2, "Check node,textnode,comment remove works" );
+ assert.ok( jQuery( "#nonnodes" ).contents().length >= 2, "Check node,textnode,comment remove works" );
jQuery( "#nonnodes" ).contents().detach();
- equal( jQuery( "#nonnodes" ).contents().length, 0, "Check node,textnode,comment remove works" );
+ assert.equal( jQuery( "#nonnodes" ).contents().length, 0, "Check node,textnode,comment remove works" );
} );
-test( "detach() event cleaning ", function() {
- expect( 1 );
+QUnit.test( "detach() event cleaning ", function( assert ) {
+ assert.expect( 1 );
var count, first, cleanUp;
@@ -2038,34 +2038,34 @@ test( "detach() event cleaning ", function() {
count++;
} ).detach().appendTo( "#qunit-fixture" ).trigger( "click" );
- strictEqual( 1, count, "Event handler has not been removed" );
+ assert.strictEqual( 1, count, "Event handler has not been removed" );
// Clean up detached data
cleanUp.remove();
} );
-test( "empty()", function() {
+QUnit.test( "empty()", function( assert ) {
- expect( 6 );
+ assert.expect( 6 );
- equal( jQuery( "#ap" ).children().empty().text().length, 0, "Check text is removed" );
- equal( jQuery( "#ap" ).children().length, 4, "Check elements are not removed" );
+ assert.equal( jQuery( "#ap" ).children().empty().text().length, 0, "Check text is removed" );
+ assert.equal( jQuery( "#ap" ).children().length, 4, "Check elements are not removed" );
// using contents will get comments regular, text, and comment nodes
var j = jQuery( "#nonnodes" ).contents();
j.empty();
- equal( j.html(), "", "Check node,textnode,comment empty works" );
+ assert.equal( j.html(), "", "Check node,textnode,comment empty works" );
// Ensure oldIE empties selects (#12336)
- notEqual( jQuery( "#select1" ).find( "option" ).length, 0, "Have some initial options" );
+ assert.notEqual( jQuery( "#select1" ).find( "option" ).length, 0, "Have some initial options" );
jQuery( "#select1" ).empty();
- equal( jQuery( "#select1" ).find( "option" ).length, 0, "No more option elements found" );
- equal( jQuery( "#select1" )[ 0 ].options.length, 0, "options.length cleared as well" );
+ assert.equal( jQuery( "#select1" ).find( "option" ).length, 0, "No more option elements found" );
+ assert.equal( jQuery( "#select1" )[ 0 ].options.length, 0, "options.length cleared as well" );
} );
-test( "jQuery.cleanData", function() {
+QUnit.test( "jQuery.cleanData", function( assert ) {
- expect( 14 );
+ assert.expect( 14 );
var type, pos, div, child;
@@ -2120,69 +2120,69 @@ test( "jQuery.cleanData", function() {
function getDiv() {
var div = jQuery( "
" ).on( "click", function() {
- ok( true, type + " " + pos + " Click event fired." );
+ assert.ok( true, type + " " + pos + " Click event fired." );
} ).on( "focus", function() {
- ok( true, type + " " + pos + " Focus event fired." );
+ assert.ok( true, type + " " + pos + " Focus event fired." );
} ).find( "div" ).on( "click", function() {
- ok( false, type + " " + pos + " Click event fired." );
+ assert.ok( false, type + " " + pos + " Click event fired." );
} ).on( "focus", function() {
- ok( false, type + " " + pos + " Focus event fired." );
+ assert.ok( false, type + " " + pos + " Focus event fired." );
} ).end().appendTo( "body" );
div[ 0 ].detachEvent = div[ 0 ].removeEventListener = function( t ) {
- ok( true, type + " Outer " + t + " event unbound" );
+ assert.ok( true, type + " Outer " + t + " event unbound" );
};
div[ 0 ].firstChild.detachEvent = div[ 0 ].firstChild.removeEventListener = function( t ) {
- ok( true, type + " Inner " + t + " event unbound" );
+ assert.ok( true, type + " Inner " + t + " event unbound" );
};
return div;
}
} );
-test( "jQuery.cleanData eliminates all private data (gh-2127)", function() {
- expect( 3 );
+QUnit.test( "jQuery.cleanData eliminates all private data (gh-2127)", function( assert ) {
+ assert.expect( 3 );
var div = jQuery( "" ).appendTo( "#qunit-fixture" );
jQuery._data( div[ 0 ], "gh-2127", "testing" );
- ok( !jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ), "Ensure some private data exists" );
+ assert.ok( !jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ), "Ensure some private data exists" );
div.remove();
- ok( !jQuery.hasData( div[ 0 ] ), "Removed element hasData should return false" );
+ assert.ok( !jQuery.hasData( div[ 0 ] ), "Removed element hasData should return false" );
- ok( jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ),
+ assert.ok( jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ),
"Private data is empty after node is removed" );
div.remove();
} );
-test( "jQuery.cleanData eliminates all public data", function() {
- expect( 2 );
+QUnit.test( "jQuery.cleanData eliminates all public data", function( assert ) {
+ assert.expect( 2 );
var key,
div = jQuery( "" );
div.data( "some", "data" );
- ok( !jQuery.isEmptyObject( jQuery.data( div[ 0 ] ) ), "Ensure some public data exists" );
+ assert.ok( !jQuery.isEmptyObject( jQuery.data( div[ 0 ] ) ), "Ensure some public data exists" );
div.remove();
- ok( !jQuery.hasData( div[ 0 ] ), "Removed element hasData should return false" );
+ assert.ok( !jQuery.hasData( div[ 0 ] ), "Removed element hasData should return false" );
// Make sure the expando is gone
for ( key in div[ 0 ] ) {
if ( /^jQuery/.test( key ) && jQuery[ key ] !== undefined ) {
- ok( false, "Expando was not removed when there was no more data" );
+ assert.ok( false, "Expando was not removed when there was no more data" );
}
}
} );
-test( "domManip plain-text caching (trac-6779)", function() {
+QUnit.test( "domManip plain-text caching (trac-6779)", function( assert ) {
- expect( 1 );
+ assert.expect( 1 );
// DOM manipulation fails if added text matches an Object method
var i,
@@ -2195,13 +2195,13 @@ test( "domManip plain-text caching (trac-6779)", function() {
}
catch ( e ) {}
}
- equal( $f.text(), bad.join( "" ), "Cached strings that match Object properties" );
+ assert.equal( $f.text(), bad.join( "" ), "Cached strings that match Object properties" );
$f.remove();
} );
-test( "domManip executes scripts containing html comments or CDATA (trac-9221)", function() {
+QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9221)", function( assert ) {
- expect( 3 );
+ assert.expect( 3 );
jQuery( [
"" );
- ok( true, "Exception ignored" );
+ assert.ok( true, "Exception ignored" );
} else {
- ok( true, "No jQuery.ajax" );
- ok( true, "No jQuery.ajax" );
+ assert.ok( true, "No jQuery.ajax" );
+ assert.ok( true, "No jQuery.ajax" );
}
};
jQuery( "#qunit-fixture" ).html( "" );
} );
-test( "checked state is cloned with clone()", function() {
+QUnit.test( "checked state is cloned with clone()", function( assert ) {
- expect( 2 );
+ assert.expect( 2 );
var elem = jQuery.parseHTML( "" )[ 0 ];
elem.checked = false;
- equal( jQuery( elem ).clone().attr( "id", "clone" )[ 0 ].checked, false, "Checked false state correctly cloned" );
+ assert.equal( jQuery( elem ).clone().attr( "id", "clone" )[ 0 ].checked, false, "Checked false state correctly cloned" );
elem = jQuery.parseHTML( "" )[ 0 ];
elem.checked = true;
- equal( jQuery( elem ).clone().attr( "id", "clone" )[ 0 ].checked, true, "Checked true state correctly cloned" );
+ assert.equal( jQuery( elem ).clone().attr( "id", "clone" )[ 0 ].checked, true, "Checked true state correctly cloned" );
} );
-test( "manipulate mixed jQuery and text (#12384, #12346)", function() {
+QUnit.test( "manipulate mixed jQuery and text (#12384, #12346)", function( assert ) {
- expect( 2 );
+ assert.expect( 2 );
var div = jQuery( "
a
" ).append( " ", jQuery( "b" ), " ", jQuery( "c" ) ),
nbsp = String.fromCharCode( 160 );
- equal( div.text(), "a" + nbsp + "b" + nbsp + "c", "Appending mixed jQuery with text nodes" );
+ assert.equal( div.text(), "a" + nbsp + "b" + nbsp + "c", "Appending mixed jQuery with text nodes" );
div = jQuery( "
" )
.find( "div" )
.after( "
a
", "
b
" )
.parent();
- equal( div.find( "*" ).length, 3, "added 2 paragraphs after inner div" );
+ assert.equal( div.find( "*" ).length, 3, "added 2 paragraphs after inner div" );
} );
-test( "script evaluation (#11795)", function() {
+QUnit.test( "script evaluation (#11795)", function( assert ) {
- expect( 13 );
+ assert.expect( 13 );
var scriptsIn, scriptsOut,
fixture = jQuery( "#qunit-fixture" ).empty(),
@@ -2450,30 +2450,30 @@ test( "script evaluation (#11795)", function() {
objGlobal.ok = isOk;
scriptsOut = fixture.append( scriptsIn ).find( "script" );
- equal( scriptsOut[ 0 ].type, "something/else", "Non-evaluated type." );
- equal( scriptsOut[ 1 ].type, "text/javascript", "Evaluated type." );
- deepEqual( scriptsOut.get(), fixture.find( "script" ).get(), "All script tags remain." );
+ assert.equal( scriptsOut[ 0 ].type, "something/else", "Non-evaluated type." );
+ assert.equal( scriptsOut[ 1 ].type, "text/javascript", "Evaluated type." );
+ assert.deepEqual( scriptsOut.get(), fixture.find( "script" ).get(), "All script tags remain." );
objGlobal.ok = notOk;
scriptsOut = scriptsOut.add( scriptsOut.clone() ).appendTo( fixture.find( "div" ) );
- deepEqual( fixture.find( "div script" ).get(), scriptsOut.get(), "Scripts cloned without reevaluation" );
+ assert.deepEqual( fixture.find( "div script" ).get(), scriptsOut.get(), "Scripts cloned without reevaluation" );
fixture.append( scriptsOut.detach() );
- deepEqual( fixture.children( "script" ).get(), scriptsOut.get(), "Scripts detached without reevaluation" );
+ assert.deepEqual( fixture.children( "script" ).get(), scriptsOut.get(), "Scripts detached without reevaluation" );
objGlobal.ok = isOk;
if ( jQuery.ajax ) {
Globals.register( "testBar" );
jQuery( "#qunit-fixture" ).append( "" );
- strictEqual( window[ "testBar" ], "bar", "Global script evaluation" );
+ assert.strictEqual( window[ "testBar" ], "bar", "Global script evaluation" );
} else {
- ok( true, "No jQuery.ajax" );
- ok( true, "No jQuery.ajax" );
+ assert.ok( true, "No jQuery.ajax" );
+ assert.ok( true, "No jQuery.ajax" );
}
} );
-test( "jQuery._evalUrl (#12838)", function() {
+QUnit.test( "jQuery._evalUrl (#12838)", function( assert ) {
- expect( 5 );
+ assert.expect( 5 );
var message, expectedArgument,
ajax = jQuery.ajax,
@@ -2482,17 +2482,17 @@ test( "jQuery._evalUrl (#12838)", function() {
message = "jQuery.ajax implementation";
expectedArgument = 1;
jQuery.ajax = function( input ) {
- equal( ( input.url || input ).slice( -1 ), expectedArgument, message );
+ assert.equal( ( input.url || input ).slice( -1 ), expectedArgument, message );
expectedArgument++;
};
jQuery( "#qunit-fixture" ).append( "" );
- equal( expectedArgument, 3, "synchronous execution" );
+ assert.equal( expectedArgument, 3, "synchronous execution" );
message = "custom implementation";
expectedArgument = 3;
jQuery._evalUrl = jQuery.ajax;
jQuery.ajax = function( options ) {
- strictEqual( options, {}, "Unexpected call to jQuery.ajax" );
+ assert.strictEqual( options, {}, "Unexpected call to jQuery.ajax" );
};
jQuery( "#qunit-fixture" ).append( "" );
@@ -2500,7 +2500,7 @@ test( "jQuery._evalUrl (#12838)", function() {
jQuery._evalUrl = evalUrl;
} );
-test( "jQuery.htmlPrefilter (gh-1747)", function( assert ) {
+QUnit.test( "jQuery.htmlPrefilter (gh-1747)", function( assert ) {
assert.expect( 5 );
@@ -2540,9 +2540,9 @@ test( "jQuery.htmlPrefilter (gh-1747)", function( assert ) {
}, 100 );
} );
-test( "insertAfter, insertBefore, etc do not work when destination is original element. Element is removed (#4087)", function() {
+QUnit.test( "insertAfter, insertBefore, etc do not work when destination is original element. Element is removed (#4087)", function( assert ) {
- expect( 10 );
+ assert.expect( 10 );
var elems;
@@ -2561,11 +2561,11 @@ test( "insertAfter, insertBefore, etc do not work when destination is original e
// complex case based on http://jsfiddle.net/pbramos/gZ7vB/
jQuery( "#test4087-complex div" )[ name ]( "#test4087-complex li:last-child div:last-child" );
- equal( jQuery( "#test4087-complex li:last-child div" ).length, name === "replaceAll" ? 1 : 2, name + " a node to itself, complex case." );
+ assert.equal( jQuery( "#test4087-complex li:last-child div" ).length, name === "replaceAll" ? 1 : 2, name + " a node to itself, complex case." );
// simple case
jQuery( ".test4087-1" )[ name ]( ".test4087-1" );
- equal( jQuery( ".test4087-1" ).length, 1, name + " a node to itself, simple case." );
+ assert.equal( jQuery( ".test4087-1" ).length, 1, name + " a node to itself, simple case." );
// clean for next test
jQuery( "#test4087-complex" ).remove();
@@ -2574,30 +2574,30 @@ test( "insertAfter, insertBefore, etc do not work when destination is original e
} );
} );
-test( "Index for function argument should be received (#13094)", function() {
- expect( 2 );
+QUnit.test( "Index for function argument should be received (#13094)", function( assert ) {
+ assert.expect( 2 );
var i = 0;
jQuery( "" ).before( function( index ) {
- equal( index, i++, "Index should be correct" );
+ assert.equal( index, i++, "Index should be correct" );
} );
} );
-test( "Make sure jQuery.fn.remove can work on elements in documentFragment", function() {
- expect( 1 );
+QUnit.test( "Make sure jQuery.fn.remove can work on elements in documentFragment", function( assert ) {
+ assert.expect( 1 );
var fragment = document.createDocumentFragment(),
div = fragment.appendChild( document.createElement( "div" ) );
jQuery( div ).remove();
- equal( fragment.childNodes.length, 0, "div element was removed from documentFragment" );
+ assert.equal( fragment.childNodes.length, 0, "div element was removed from documentFragment" );
} );
-test( "Make sure tr element will be appended to tbody element of table when present", function() {
- expect( 1 );
+QUnit.test( "Make sure tr element will be appended to tbody element of table when present", function( assert ) {
+ assert.expect( 1 );
var html,
table = document.createElement( "table" );
@@ -2610,11 +2610,11 @@ test( "Make sure tr element will be appended to tbody element of table when pres
// Lowercase and replace spaces to remove possible browser inconsistencies
html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
- strictEqual( html, "
test
" );
+ assert.strictEqual( html, "
test
" );
} );
-test( "Make sure tr elements will be appended to tbody element of table when present", function() {
- expect( 1 );
+QUnit.test( "Make sure tr elements will be appended to tbody element of table when present", function( assert ) {
+ assert.expect( 1 );
var html,
table = document.createElement( "table" );
@@ -2627,11 +2627,11 @@ test( "Make sure tr elements will be appended to tbody element of table when pre
// Lowercase and replace spaces to remove possible browser inconsistencies
html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
- strictEqual( html, "
1
2
" );
+ assert.strictEqual( html, "
1
2
" );
} );
-test( "Make sure tfoot element will not be appended to tbody element of table when present", function() {
- expect( 1 );
+QUnit.test( "Make sure tfoot element will not be appended to tbody element of table when present", function( assert ) {
+ assert.expect( 1 );
var html,
table = document.createElement( "table" );
@@ -2644,11 +2644,11 @@ test( "Make sure tfoot element will not be appended to tbody element of table wh
// Lowercase and replace spaces to remove possible browser inconsistencies
html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
- strictEqual( html, "" );
+ assert.strictEqual( html, "" );
} );
-test( "Make sure document fragment will be appended to tbody element of table when present", function() {
- expect( 1 );
+QUnit.test( "Make sure document fragment will be appended to tbody element of table when present", function( assert ) {
+ assert.expect( 1 );
var html,
fragment = document.createDocumentFragment(),
@@ -2668,11 +2668,11 @@ test( "Make sure document fragment will be appended to tbody element of table wh
// Lowercase and replace spaces to remove possible browser inconsistencies
html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
- strictEqual( html, "
test
" );
+ assert.strictEqual( html, "
test
" );
} );
-test( "Make sure col element is appended correctly", function() {
- expect( 1 );
+QUnit.test( "Make sure col element is appended correctly", function( assert ) {
+ assert.expect( 1 );
var table = jQuery( "
test
" );
@@ -2680,10 +2680,10 @@ test( "Make sure col element is appended correctly", function() {
jQuery( "
" ).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( "" );
@@ -564,14 +564,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;
@@ -581,8 +581,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 {
@@ -599,8 +599,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()" );
}
} );
diff --git a/test/unit/queue.js b/test/unit/queue.js
index 50a630fb4..7ce85cb35 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -1,147 +1,147 @@
-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( "
" ),
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( "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;
@@ -155,17 +155,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;
@@ -178,52 +178,52 @@ 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;
@@ -233,43 +233,43 @@ 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" )
@@ -280,33 +280,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();
};
} );
diff --git a/test/unit/ready.js b/test/unit/ready.js
index ee39dec9d..9c7ce74ff 100644
--- a/test/unit/ready.js
+++ b/test/unit/ready.js
@@ -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" );
} );
diff --git a/test/unit/selector.js b/test/unit/selector.js
index c9afeb0dc..1c15a3df8 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -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, " cannot be found under IE, see #945" );
- ok( jQuery( "#lengthtest input" ).length, " cannot be found under IE, see #945" );
+ assert.ok( jQuery( "#length" ).length, " cannot be found under IE, see #945" );
+ assert.ok( jQuery( "#lengthtest input" ).length, " cannot be found under IE, see #945" );
// #7533
- equal( jQuery( "
foo
" ).find( "p" ).length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" );
+ assert.equal( jQuery( "
foo
" ).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( "" ).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( "
" );
- equal( fixture.find( "h2, div p" ).filter( "p" ).length, 2, "has to find two
" );
- equal( fixture.find( "h2, div p" ).filter( "h2" ).length, 1, "has to find one
" );
- equal( fixture.find( "h2 , div p" ).filter( "p" ).length, 2, "has to find two
" );
- equal( fixture.find( "h2 , div p" ).filter( "h2" ).length, 1, "has to find one
" );
+ assert.equal( fixture.find( "h2, div p" ).filter( "p" ).length, 2, "has to find two
" );
+ assert.equal( fixture.find( "h2, div p" ).filter( "h2" ).length, 1, "has to find one
" );
+ assert.equal( fixture.find( "h2 , div p" ).filter( "p" ).length, 2, "has to find two
" );
+ assert.equal( fixture.find( "h2 , div p" ).filter( "h2" ).length, 1, "has to find one
" );
} );
-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-existant 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( "
" );
- 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,159 +234,163 @@ test( "attributes", function() {
t( "Value attribute is retrieved correctly", "input[value=Test]", [ "text1", "text2" ] );
// #12600
- ok(
+ assert.ok(
jQuery( "" )
.prop( "value", "option" )
.is( ":input[value='12600']" ),
":input[value=foo] selects select by attribute"
);
- ok( jQuery( "" ).prop( "value", "option" ).is( ":input[value='12600']" ),
+ assert.ok( jQuery( "" ).prop( "value", "option" ).is( ":input[value='12600']" ),
":input[value=foo] selects text input by attribute"
);
// #11115
- ok( jQuery( "" ).prop( "checked", false ).is( "[checked]" ),
+ assert.ok( jQuery( "" ).prop( "checked", false ).is( "[checked]" ),
"[checked] selects by attribute (positive)"
);
- ok( !jQuery( "" ).prop( "checked", true ).is( "[checked]" ),
+ assert.ok( !jQuery( "" ).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( "" );
- 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( "" ).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( 37 );
+testIframe(
+ "selector/html5_selector",
+ "attributes - jQuery.attr",
+ function( jQuery, window, document, assert ) {
+ assert.expect( 37 );
- /**
- * 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"] ); // sigh, FF12 QSA mistakenly includes video elements even though they have no tabindex attribute (see https://bugzilla.mozilla.org/show_bug.cgi?id=618737)
+ 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"] ); // sigh, FF12 QSA mistakenly includes video elements even though they have no tabindex attribute (see https://bugzilla.mozilla.org/show_bug.cgi?id=618737)
- 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;
@@ -459,24 +463,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" ),
@@ -493,12 +501,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();
diff --git a/test/unit/serialize.js b/test/unit/serialize.js
index d3def19a1..047861530 100644
--- a/test/unit/serialize.js
+++ b/test/unit/serialize.js
@@ -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() {
""
);
- 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();
diff --git a/test/unit/support.js b/test/unit/support.js
index 80242257e..6d97fa6f8 100644
--- a/test/unit/support.js
+++ b/test/unit/support.js
@@ -1,4 +1,4 @@
-module( "support", { teardown: moduleTeardown } );
+QUnit.module( "support", { teardown: moduleTeardown } );
function getComputedSupport( support ) {
var prop,
@@ -17,48 +17,56 @@ function getComputedSupport( support ) {
var computedSupport = getComputedSupport( jQuery.support );
-test( "zoom of doom (#13089)", function() {
- expect( 1 );
+QUnit.test( "zoom of doom (#13089)", function( assert ) {
+ assert.expect( 1 );
- ok( !document.body.style.zoom, "No zoom added to the body" );
+ assert.ok( !document.body.style.zoom, "No zoom added to the body" );
} );
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 + ")" );
- stop();
+ QUnit.stop();
- // Run doc ready tests as well
- jQuery( function() {
- deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
- start();
- } );
- } );
+ // Run doc ready tests as well
+ jQuery( function() {
+ assert.deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
+ QUnit.start();
+ } );
+ }
+ );
}
-testIframeWithCallback( "A background on the testElement does not cause IE8 to crash (#9823)", "support/testElementCrash.html", function() {
- expect( 1 );
- ok( true, "IE8 does not crash" );
-} );
+testIframeWithCallback(
+ "A background on the testElement does not cause IE8 to crash (#9823)",
+ "support/testElementCrash.html", function( assert ) {
+ assert.expect( 1 );
+ assert.ok( true, "IE8 does not crash" );
+ }
+);
// 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 );
} );
}
@@ -470,7 +478,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;
@@ -478,15 +486,15 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
j++;
}
- expect( j );
+ assert.expect( j );
for ( i in expected ) {
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 + "']" );
}
}
} );
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index b5ccf6d35..5d30f85b1 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -1,30 +1,30 @@
-module( "traversing", { teardown: moduleTeardown } );
+QUnit.module( "traversing", { teardown: moduleTeardown } );
-test( "find(String)", function() {
- expect( 1 );
- equal( jQuery( "#foo" ).find( ".blogTest" ).text(), "Yahoo", "Basic selector" );
+QUnit.test( "find(String)", function( assert ) {
+ assert.expect( 1 );
+ assert.equal( jQuery( "#foo" ).find( ".blogTest" ).text(), "Yahoo", "Basic selector" );
} );
-test( "find(String) under non-elements", function() {
- expect( 2 );
+QUnit.test( "find(String) under non-elements", function( assert ) {
+ assert.expect( 2 );
var j = jQuery( "#nonnodes" ).contents();
- equal( j.find( "div" ).length, 0, "Check node,textnode,comment to find zero divs" );
- equal( j.find( "div" ).addBack().length, 3, "Check node,textnode,comment to find zero divs, but preserves pushStack" );
+ assert.equal( j.find( "div" ).length, 0, "Check node,textnode,comment to find zero divs" );
+ assert.equal( j.find( "div" ).addBack().length, 3, "Check node,textnode,comment to find zero divs, but preserves pushStack" );
} );
-test( "find(leading combinator)", function() {
- expect( 4 );
+QUnit.test( "find(leading combinator)", function( assert ) {
+ assert.expect( 4 );
- deepEqual( jQuery( "#qunit-fixture" ).find( "> div" ).get(), q( "foo", "nothiddendiv", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" );
- deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo, > #moretests" ).get(), q( "foo", "moretests" ), "find child elements" );
- deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo > p" ).get(), q( "sndp", "en", "sap" ), "find child elements" );
+ assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> div" ).get(), q( "foo", "nothiddendiv", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" );
+ assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo, > #moretests" ).get(), q( "foo", "moretests" ), "find child elements" );
+ assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo > p" ).get(), q( "sndp", "en", "sap" ), "find child elements" );
- deepEqual( jQuery( "#siblingTest, #siblingfirst" ).find( "+ *" ).get(), q( "siblingnext", "fx-test-group" ), "ensure document order" );
+ assert.deepEqual( jQuery( "#siblingTest, #siblingfirst" ).find( "+ *" ).get(), q( "siblingnext", "fx-test-group" ), "ensure document order" );
} );
-test( "find(node|jQuery object)", function() {
- expect( 13 );
+QUnit.test( "find(node|jQuery object)", function( assert ) {
+ assert.expect( 13 );
var $foo = jQuery( "#foo" ),
$blog = jQuery( ".blogTest" ),
@@ -33,55 +33,55 @@ test( "find(node|jQuery object)", function() {
$twoMore = jQuery( "#ap" ).add( $blog ),
$fooTwo = $foo.add( $blog );
- equal( $foo.find( $blog ).text(), "Yahoo", "Find with blog jQuery object" );
- equal( $foo.find( $blog[ 0 ] ).text(), "Yahoo", "Find with blog node" );
- equal( $foo.find( $first ).length, 0, "#first is not in #foo" );
- equal( $foo.find( $first[ 0 ] ).length, 0, "#first not in #foo (node)" );
- deepEqual( $foo.find( $two ).get(), $blog.get(), "Find returns only nodes within #foo" );
- deepEqual( $foo.find( $twoMore ).get(), $blog.get(), "...regardless of order" );
- ok( $fooTwo.find( $blog ).is( ".blogTest" ), "Blog is part of the collection, but also within foo" );
- ok( $fooTwo.find( $blog[ 0 ] ).is( ".blogTest" ), "Blog is part of the collection, but also within foo(node)" );
+ assert.equal( $foo.find( $blog ).text(), "Yahoo", "Find with blog jQuery object" );
+ assert.equal( $foo.find( $blog[ 0 ] ).text(), "Yahoo", "Find with blog node" );
+ assert.equal( $foo.find( $first ).length, 0, "#first is not in #foo" );
+ assert.equal( $foo.find( $first[ 0 ] ).length, 0, "#first not in #foo (node)" );
+ assert.deepEqual( $foo.find( $two ).get(), $blog.get(), "Find returns only nodes within #foo" );
+ assert.deepEqual( $foo.find( $twoMore ).get(), $blog.get(), "...regardless of order" );
+ assert.ok( $fooTwo.find( $blog ).is( ".blogTest" ), "Blog is part of the collection, but also within foo" );
+ assert.ok( $fooTwo.find( $blog[ 0 ] ).is( ".blogTest" ), "Blog is part of the collection, but also within foo(node)" );
- equal( $two.find( $foo ).length, 0, "Foo is not in two elements" );
- equal( $two.find( $foo[ 0 ] ).length, 0, "Foo is not in two elements(node)" );
- equal( $two.find( $first ).length, 0, "first is in the collection and not within two" );
- equal( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" );
+ assert.equal( $two.find( $foo ).length, 0, "Foo is not in two elements" );
+ assert.equal( $two.find( $foo[ 0 ] ).length, 0, "Foo is not in two elements(node)" );
+ assert.equal( $two.find( $first ).length, 0, "first is in the collection and not within two" );
+ assert.equal( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" );
- equal( $two.find( $foo[ 0 ] ).addBack().length, 2, "find preserves the pushStack, see #12009" );
+ assert.equal( $two.find( $foo[ 0 ] ).addBack().length, 2, "find preserves the pushStack, see #12009" );
} );
-test( "is(String|undefined)", function() {
- expect( 23 );
- ok( jQuery( "#form" ).is( "form" ), "Check for element: A form must be a form" );
- ok( !jQuery( "#form" ).is( "div" ), "Check for element: A form is not a div" );
- ok( jQuery( "#mark" ).is( ".blog" ), "Check for class: Expected class 'blog'" );
- ok( !jQuery( "#mark" ).is( ".link" ), "Check for class: Did not expect class 'link'" );
- ok( jQuery( "#simon" ).is( ".blog.link" ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
- ok( !jQuery( "#simon" ).is( ".blogTest" ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
- ok( jQuery( "#en" ).is( "[lang=\"en\"]" ), "Check for attribute: Expected attribute lang to be 'en'" );
- ok( !jQuery( "#en" ).is( "[lang=\"de\"]" ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
- ok( jQuery( "#text1" ).is( "[type=\"text\"]" ), "Check for attribute: Expected attribute type to be 'text'" );
- ok( !jQuery( "#text1" ).is( "[type=\"radio\"]" ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
- ok( jQuery( "#text2" ).is( ":disabled" ), "Check for pseudoclass: Expected to be disabled" );
- ok( !jQuery( "#text1" ).is( ":disabled" ), "Check for pseudoclass: Expected not disabled" );
- ok( jQuery( "#radio2" ).is( ":checked" ), "Check for pseudoclass: Expected to be checked" );
- ok( !jQuery( "#radio1" ).is( ":checked" ), "Check for pseudoclass: Expected not checked" );
+QUnit.test( "is(String|undefined)", function( assert ) {
+ assert.expect( 23 );
+ assert.ok( jQuery( "#form" ).is( "form" ), "Check for element: A form must be a form" );
+ assert.ok( !jQuery( "#form" ).is( "div" ), "Check for element: A form is not a div" );
+ assert.ok( jQuery( "#mark" ).is( ".blog" ), "Check for class: Expected class 'blog'" );
+ assert.ok( !jQuery( "#mark" ).is( ".link" ), "Check for class: Did not expect class 'link'" );
+ assert.ok( jQuery( "#simon" ).is( ".blog.link" ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
+ assert.ok( !jQuery( "#simon" ).is( ".blogTest" ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
+ assert.ok( jQuery( "#en" ).is( "[lang=\"en\"]" ), "Check for attribute: Expected attribute lang to be 'en'" );
+ assert.ok( !jQuery( "#en" ).is( "[lang=\"de\"]" ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
+ assert.ok( jQuery( "#text1" ).is( "[type=\"text\"]" ), "Check for attribute: Expected attribute type to be 'text'" );
+ assert.ok( !jQuery( "#text1" ).is( "[type=\"radio\"]" ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
+ assert.ok( jQuery( "#text2" ).is( ":disabled" ), "Check for pseudoclass: Expected to be disabled" );
+ assert.ok( !jQuery( "#text1" ).is( ":disabled" ), "Check for pseudoclass: Expected not disabled" );
+ assert.ok( jQuery( "#radio2" ).is( ":checked" ), "Check for pseudoclass: Expected to be checked" );
+ assert.ok( !jQuery( "#radio1" ).is( ":checked" ), "Check for pseudoclass: Expected not checked" );
- ok( !jQuery( "#foo" ).is( 0 ), "Expected false for an invalid expression - 0" );
- ok( !jQuery( "#foo" ).is( null ), "Expected false for an invalid expression - null" );
- ok( !jQuery( "#foo" ).is( "" ), "Expected false for an invalid expression - \"\"" );
- ok( !jQuery( "#foo" ).is( undefined ), "Expected false for an invalid expression - undefined" );
- ok( !jQuery( "#foo" ).is( { plain: "object" } ), "Check passing invalid object" );
+ assert.ok( !jQuery( "#foo" ).is( 0 ), "Expected false for an invalid expression - 0" );
+ assert.ok( !jQuery( "#foo" ).is( null ), "Expected false for an invalid expression - null" );
+ assert.ok( !jQuery( "#foo" ).is( "" ), "Expected false for an invalid expression - \"\"" );
+ assert.ok( !jQuery( "#foo" ).is( undefined ), "Expected false for an invalid expression - undefined" );
+ assert.ok( !jQuery( "#foo" ).is( { plain: "object" } ), "Check passing invalid object" );
// test is() with comma-separated expressions
- ok( jQuery( "#en" ).is( "[lang=\"en\"],[lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
- ok( jQuery( "#en" ).is( "[lang=\"de\"],[lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
- ok( jQuery( "#en" ).is( "[lang=\"en\"] , [lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
- ok( jQuery( "#en" ).is( "[lang=\"de\"] , [lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
+ assert.ok( jQuery( "#en" ).is( "[lang=\"en\"],[lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
+ assert.ok( jQuery( "#en" ).is( "[lang=\"de\"],[lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
+ assert.ok( jQuery( "#en" ).is( "[lang=\"en\"] , [lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
+ assert.ok( jQuery( "#en" ).is( "[lang=\"de\"] , [lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" );
} );
-test( "is() against non-elements (#10178)", function() {
- expect( 14 );
+QUnit.test( "is() against non-elements (#10178)", function( assert ) {
+ assert.expect( 14 );
var label, i, test,
collection = jQuery( document ),
@@ -100,50 +100,50 @@ test( "is() against non-elements (#10178)", function() {
collection[ 0 ] = nonelements[ label ];
for ( i = 0; i < tests.length; i++ ) {
test = tests[ i ];
- ok( !collection.is( test ), label + " does not match \"" + test + "\"" );
+ assert.ok( !collection.is( test ), label + " does not match \"" + test + "\"" );
}
}
} );
-test( "is(jQuery)", function() {
- expect( 19 );
- ok( jQuery( "#form" ).is( jQuery( "form" ) ), "Check for element: A form is a form" );
- ok( !jQuery( "#form" ).is( jQuery( "div" ) ), "Check for element: A form is not a div" );
- ok( jQuery( "#mark" ).is( jQuery( ".blog" ) ), "Check for class: Expected class 'blog'" );
- ok( !jQuery( "#mark" ).is( jQuery( ".link" ) ), "Check for class: Did not expect class 'link'" );
- ok( jQuery( "#simon" ).is( jQuery( ".blog.link" ) ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
- ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" ) ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
- ok( jQuery( "#en" ).is( jQuery( "[lang=\"en\"]" ) ), "Check for attribute: Expected attribute lang to be 'en'" );
- ok( !jQuery( "#en" ).is( jQuery( "[lang=\"de\"]" ) ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
- ok( jQuery( "#text1" ).is( jQuery( "[type=\"text\"]" ) ), "Check for attribute: Expected attribute type to be 'text'" );
- ok( !jQuery( "#text1" ).is( jQuery( "[type=\"radio\"]" ) ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
- ok( !jQuery( "#text1" ).is( jQuery( "input:disabled" ) ), "Check for pseudoclass: Expected not disabled" );
- ok( jQuery( "#radio2" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected to be checked" );
- ok( !jQuery( "#radio1" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected not checked" );
+QUnit.test( "is(jQuery)", function( assert ) {
+ assert.expect( 19 );
+ assert.ok( jQuery( "#form" ).is( jQuery( "form" ) ), "Check for element: A form is a form" );
+ assert.ok( !jQuery( "#form" ).is( jQuery( "div" ) ), "Check for element: A form is not a div" );
+ assert.ok( jQuery( "#mark" ).is( jQuery( ".blog" ) ), "Check for class: Expected class 'blog'" );
+ assert.ok( !jQuery( "#mark" ).is( jQuery( ".link" ) ), "Check for class: Did not expect class 'link'" );
+ assert.ok( jQuery( "#simon" ).is( jQuery( ".blog.link" ) ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
+ assert.ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" ) ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
+ assert.ok( jQuery( "#en" ).is( jQuery( "[lang=\"en\"]" ) ), "Check for attribute: Expected attribute lang to be 'en'" );
+ assert.ok( !jQuery( "#en" ).is( jQuery( "[lang=\"de\"]" ) ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" );
+ assert.ok( jQuery( "#text1" ).is( jQuery( "[type=\"text\"]" ) ), "Check for attribute: Expected attribute type to be 'text'" );
+ assert.ok( !jQuery( "#text1" ).is( jQuery( "[type=\"radio\"]" ) ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" );
+ assert.ok( !jQuery( "#text1" ).is( jQuery( "input:disabled" ) ), "Check for pseudoclass: Expected not disabled" );
+ assert.ok( jQuery( "#radio2" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected to be checked" );
+ assert.ok( !jQuery( "#radio1" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected not checked" );
// Some raw elements
- ok( jQuery( "#form" ).is( jQuery( "#qunit-fixture form" )[ 0 ] ), "Check for element: A form is a form" );
- ok( !jQuery( "#form" ).is( jQuery( "div" )[ 0 ] ), "Check for element: A form is not a div" );
- ok( jQuery( "#mark" ).is( jQuery( ".blog" )[ 0 ] ), "Check for class: Expected class 'blog'" );
- ok( !jQuery( "#mark" ).is( jQuery( ".link" )[ 0 ] ), "Check for class: Did not expect class 'link'" );
- ok( jQuery( "#simon" ).is( jQuery( ".blog.link" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
- ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
+ assert.ok( jQuery( "#form" ).is( jQuery( "#qunit-fixture form" )[ 0 ] ), "Check for element: A form is a form" );
+ assert.ok( !jQuery( "#form" ).is( jQuery( "div" )[ 0 ] ), "Check for element: A form is not a div" );
+ assert.ok( jQuery( "#mark" ).is( jQuery( ".blog" )[ 0 ] ), "Check for class: Expected class 'blog'" );
+ assert.ok( !jQuery( "#mark" ).is( jQuery( ".link" )[ 0 ] ), "Check for class: Did not expect class 'link'" );
+ assert.ok( jQuery( "#simon" ).is( jQuery( ".blog.link" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link'" );
+ assert.ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
} );
-test( "is() with :has() selectors", function() {
- expect( 6 );
+QUnit.test( "is() with :has() selectors", function( assert ) {
+ assert.expect( 6 );
- ok( jQuery( "#foo" ).is( ":has(p)" ), "Check for child: Expected a child 'p' element" );
- ok( !jQuery( "#foo" ).is( ":has(ul)" ), "Check for child: Did not expect 'ul' element" );
- ok( jQuery( "#foo" ).is( ":has(p):has(a):has(code)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements" );
- ok( !jQuery( "#foo" ).is( ":has(p):has(a):has(code):has(ol)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements, but no 'ol'" );
+ assert.ok( jQuery( "#foo" ).is( ":has(p)" ), "Check for child: Expected a child 'p' element" );
+ assert.ok( !jQuery( "#foo" ).is( ":has(ul)" ), "Check for child: Did not expect 'ul' element" );
+ assert.ok( jQuery( "#foo" ).is( ":has(p):has(a):has(code)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements" );
+ assert.ok( !jQuery( "#foo" ).is( ":has(p):has(a):has(code):has(ol)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements, but no 'ol'" );
- ok( jQuery( "#foo" ).is( jQuery( "div:has(p)" ) ), "Check for child: Expected a child 'p' element" );
- ok( !jQuery( "#foo" ).is( jQuery( "div:has(ul)" ) ), "Check for child: Did not expect 'ul' element" );
+ assert.ok( jQuery( "#foo" ).is( jQuery( "div:has(p)" ) ), "Check for child: Expected a child 'p' element" );
+ assert.ok( !jQuery( "#foo" ).is( jQuery( "div:has(ul)" ) ), "Check for child: Did not expect 'ul' element" );
} );
-test( "is() with positional selectors", function() {
- expect( 27 );
+QUnit.test( "is() with positional selectors", function( assert ) {
+ assert.expect( 27 );
var
posp = jQuery(
@@ -151,7 +151,7 @@ test( "is() with positional selectors", function() {
"test"
).appendTo( "#qunit-fixture" ),
isit = function( sel, match, expect ) {
- equal(
+ assert.equal(
jQuery( sel ).is( match ),
expect,
"jQuery('" + sel + "').is('" + match + "')"
@@ -186,104 +186,104 @@ test( "is() with positional selectors", function() {
isit( "#posp em", "#posp a em:last", true );
isit( "#posp em", "#posp a em:eq(2)", false );
- ok( jQuery( "#option1b" ).is( "#select1 option:not(:first)" ), "POS inside of :not() (#10970)" );
+ assert.ok( jQuery( "#option1b" ).is( "#select1 option:not(:first)" ), "POS inside of :not() (#10970)" );
- ok( jQuery( posp[ 0 ] ).is( "p:last" ), "context constructed from a single node (#13797)" );
- ok( !jQuery( posp[ 0 ] ).find( "#firsta" ).is( "a:first" ), "context derived from a single node (#13797)" );
+ assert.ok( jQuery( posp[ 0 ] ).is( "p:last" ), "context constructed from a single node (#13797)" );
+ assert.ok( !jQuery( posp[ 0 ] ).find( "#firsta" ).is( "a:first" ), "context derived from a single node (#13797)" );
} );
-test( "index()", function() {
- expect( 2 );
+QUnit.test( "index()", function( assert ) {
+ assert.expect( 2 );
- equal( jQuery( "#text2" ).index(), 2, "Returns the index of a child amongst its siblings" );
+ assert.equal( jQuery( "#text2" ).index(), 2, "Returns the index of a child amongst its siblings" );
- equal( jQuery( "" ).index(), -1, "Node without parent returns -1" );
+ assert.equal( jQuery( "" ).index(), -1, "Node without parent returns -1" );
} );
-test( "index(Object|String|undefined)", function() {
- expect( 16 );
+QUnit.test( "index(Object|String|undefined)", function( assert ) {
+ assert.expect( 16 );
var elements = jQuery( [ window, document ] ),
inputElements = jQuery( "#radio1,#radio2,#check1,#check2" );
// Passing a node
- equal( elements.index( window ), 0, "Check for index of elements" );
- equal( elements.index( document ), 1, "Check for index of elements" );
- equal( inputElements.index( document.getElementById( "radio1" ) ), 0, "Check for index of elements" );
- equal( inputElements.index( document.getElementById( "radio2" ) ), 1, "Check for index of elements" );
- equal( inputElements.index( document.getElementById( "check1" ) ), 2, "Check for index of elements" );
- equal( inputElements.index( document.getElementById( "check2" ) ), 3, "Check for index of elements" );
- equal( inputElements.index( window ), -1, "Check for not found index" );
- equal( inputElements.index( document ), -1, "Check for not found index" );
+ assert.equal( elements.index( window ), 0, "Check for index of elements" );
+ assert.equal( elements.index( document ), 1, "Check for index of elements" );
+ assert.equal( inputElements.index( document.getElementById( "radio1" ) ), 0, "Check for index of elements" );
+ assert.equal( inputElements.index( document.getElementById( "radio2" ) ), 1, "Check for index of elements" );
+ assert.equal( inputElements.index( document.getElementById( "check1" ) ), 2, "Check for index of elements" );
+ assert.equal( inputElements.index( document.getElementById( "check2" ) ), 3, "Check for index of elements" );
+ assert.equal( inputElements.index( window ), -1, "Check for not found index" );
+ assert.equal( inputElements.index( document ), -1, "Check for not found index" );
// Passing a jQuery object
// enabled since [5500]
- equal( elements.index( elements ), 0, "Pass in a jQuery object" );
- equal( elements.index( elements.eq( 1 ) ), 1, "Pass in a jQuery object" );
- equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Pass in a jQuery object" );
+ assert.equal( elements.index( elements ), 0, "Pass in a jQuery object" );
+ assert.equal( elements.index( elements.eq( 1 ) ), 1, "Pass in a jQuery object" );
+ assert.equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Pass in a jQuery object" );
// Passing a selector or nothing
// enabled since [6330]
- equal( jQuery( "#text2" ).index(), 2, "Check for index amongst siblings" );
- equal( jQuery( "#form" ).children().eq( 4 ).index(), 4, "Check for index amongst siblings" );
- equal( jQuery( "#radio2" ).index( "#form input[type='radio']" ), 1, "Check for index within a selector" );
- equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Check for index within a selector" );
- equal( jQuery( "#radio2" ).index( "#form input[type='text']" ), -1, "Check for index not found within a selector" );
+ assert.equal( jQuery( "#text2" ).index(), 2, "Check for index amongst siblings" );
+ assert.equal( jQuery( "#form" ).children().eq( 4 ).index(), 4, "Check for index amongst siblings" );
+ assert.equal( jQuery( "#radio2" ).index( "#form input[type='radio']" ), 1, "Check for index within a selector" );
+ assert.equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Check for index within a selector" );
+ assert.equal( jQuery( "#radio2" ).index( "#form input[type='text']" ), -1, "Check for index not found within a selector" );
} );
-test( "filter(Selector|undefined)", function() {
- expect( 9 );
- deepEqual( jQuery( "#form input" ).filter( ":checked" ).get(), q( "radio2", "check1" ), "filter(String)" );
- deepEqual( jQuery( "p" ).filter( "#ap, #sndp" ).get(), q( "ap", "sndp" ), "filter('String, String')" );
- deepEqual( jQuery( "p" ).filter( "#ap,#sndp" ).get(), q( "ap", "sndp" ), "filter('String,String')" );
+QUnit.test( "filter(Selector|undefined)", function( assert ) {
+ assert.expect( 9 );
+ assert.deepEqual( jQuery( "#form input" ).filter( ":checked" ).get(), q( "radio2", "check1" ), "filter(String)" );
+ assert.deepEqual( jQuery( "p" ).filter( "#ap, #sndp" ).get(), q( "ap", "sndp" ), "filter('String, String')" );
+ assert.deepEqual( jQuery( "p" ).filter( "#ap,#sndp" ).get(), q( "ap", "sndp" ), "filter('String,String')" );
- deepEqual( jQuery( "p" ).filter( null ).get(), [], "filter(null) should return an empty jQuery object" );
- deepEqual( jQuery( "p" ).filter( undefined ).get(), [], "filter(undefined) should return an empty jQuery object" );
- deepEqual( jQuery( "p" ).filter( 0 ).get(), [], "filter(0) should return an empty jQuery object" );
- deepEqual( jQuery( "p" ).filter( "" ).get(), [], "filter('') should return an empty jQuery object" );
+ assert.deepEqual( jQuery( "p" ).filter( null ).get(), [], "filter(null) should return an empty jQuery object" );
+ assert.deepEqual( jQuery( "p" ).filter( undefined ).get(), [], "filter(undefined) should return an empty jQuery object" );
+ assert.deepEqual( jQuery( "p" ).filter( 0 ).get(), [], "filter(0) should return an empty jQuery object" );
+ assert.deepEqual( jQuery( "p" ).filter( "" ).get(), [], "filter('') should return an empty jQuery object" );
// using contents will get comments regular, text, and comment nodes
var j = jQuery( "#nonnodes" ).contents();
- equal( j.filter( "span" ).length, 1, "Check node,textnode,comment to filter the one span" );
- equal( j.filter( "[name]" ).length, 0, "Check node,textnode,comment to filter the one span" );
+ assert.equal( j.filter( "span" ).length, 1, "Check node,textnode,comment to filter the one span" );
+ assert.equal( j.filter( "[name]" ).length, 0, "Check node,textnode,comment to filter the one span" );
} );
-test( "filter(Function)", function() {
- expect( 2 );
+QUnit.test( "filter(Function)", function( assert ) {
+ assert.expect( 2 );
- deepEqual( jQuery( "#qunit-fixture p" ).filter( function() {
+ assert.deepEqual( jQuery( "#qunit-fixture p" ).filter( function() {
return !jQuery( "a", this ).length;
} ).get(), q( "sndp", "first" ), "filter(Function)" );
- deepEqual( jQuery( "#qunit-fixture p" ).filter( function( i, elem ) { return !jQuery( "a", elem ).length; } ).get(), q( "sndp", "first" ), "filter(Function) using arg" );
+ assert.deepEqual( jQuery( "#qunit-fixture p" ).filter( function( i, elem ) { return !jQuery( "a", elem ).length; } ).get(), q( "sndp", "first" ), "filter(Function) using arg" );
} );
-test( "filter(Element)", function() {
- expect( 1 );
+QUnit.test( "filter(Element)", function( assert ) {
+ assert.expect( 1 );
var element = document.getElementById( "text1" );
- deepEqual( jQuery( "#form input" ).filter( element ).get(), q( "text1" ), "filter(Element)" );
+ assert.deepEqual( jQuery( "#form input" ).filter( element ).get(), q( "text1" ), "filter(Element)" );
} );
-test( "filter(Array)", function() {
- expect( 1 );
+QUnit.test( "filter(Array)", function( assert ) {
+ assert.expect( 1 );
var elements = [ document.getElementById( "text1" ) ];
- deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
+ assert.deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
} );
-test( "filter(jQuery)", function() {
- expect( 1 );
+QUnit.test( "filter(jQuery)", function( assert ) {
+ assert.expect( 1 );
var elements = jQuery( "#text1" );
- deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
+ assert.deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" );
} );
-test( "filter() with positional selectors", function() {
- expect( 19 );
+QUnit.test( "filter() with positional selectors", function( assert ) {
+ assert.expect( 19 );
var filterit = function( sel, filter, length ) {
- equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
+ assert.equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
};
jQuery( "" +
@@ -322,360 +322,360 @@ test( "filter() with positional selectors", function() {
filterit( "#posp .seconda", "#posp a:lt(1)", 1 );
} );
-test( "closest()", function() {
- expect( 13 );
+QUnit.test( "closest()", function( assert ) {
+ assert.expect( 13 );
var jq;
- deepEqual( jQuery( "body" ).closest( "body" ).get(), q( "body" ), "closest(body)" );
- deepEqual( jQuery( "body" ).closest( "html" ).get(), q( "html" ), "closest(html)" );
- deepEqual( jQuery( "body" ).closest( "div" ).get(), [], "closest(div)" );
- deepEqual( jQuery( "#qunit-fixture" ).closest( "span,#html" ).get(), q( "html" ), "closest(span,#html)" );
+ assert.deepEqual( jQuery( "body" ).closest( "body" ).get(), q( "body" ), "closest(body)" );
+ assert.deepEqual( jQuery( "body" ).closest( "html" ).get(), q( "html" ), "closest(html)" );
+ assert.deepEqual( jQuery( "body" ).closest( "div" ).get(), [], "closest(div)" );
+ assert.deepEqual( jQuery( "#qunit-fixture" ).closest( "span,#html" ).get(), q( "html" ), "closest(span,#html)" );
// Test .closest() limited by the context
jq = jQuery( "#nothiddendivchild" );
- deepEqual( jq.closest( "html", document.body ).get(), [], "Context limited." );
- deepEqual( jq.closest( "body", document.body ).get(), [], "Context limited." );
- deepEqual( jq.closest( "#nothiddendiv", document.body ).get(), q( "nothiddendiv" ), "Context not reached." );
+ assert.deepEqual( jq.closest( "html", document.body ).get(), [], "Context limited." );
+ assert.deepEqual( jq.closest( "body", document.body ).get(), [], "Context limited." );
+ assert.deepEqual( jq.closest( "#nothiddendiv", document.body ).get(), q( "nothiddendiv" ), "Context not reached." );
//Test that .closest() returns unique'd set
- equal( jQuery( "#qunit-fixture p" ).closest( "#qunit-fixture" ).length, 1, "Closest should return a unique set" );
+ assert.equal( jQuery( "#qunit-fixture p" ).closest( "#qunit-fixture" ).length, 1, "Closest should return a unique set" );
// Test on disconnected node
- equal( jQuery( "
" );
- equal( jQuery( "div", ibody ).length, 2, "Check the original div and the new div are in IFrame" );
+ assert.equal( jQuery( "div", ibody ).length, 2, "Check the original div and the new div are in IFrame" );
- equal( jQuery( "div", ibody ).last().text(), "init text", "Add text to div in IFrame" );
+ assert.equal( jQuery( "div", ibody ).last().text(), "init text", "Add text to div in IFrame" );
jQuery( "div", ibody ).last().text( "div text" );
- equal( jQuery( "div", ibody ).last().text(), "div text", "Add text to div in IFrame" );
+ assert.equal( jQuery( "div", ibody ).last().text(), "div text", "Add text to div in IFrame" );
jQuery( "div", ibody ).last().remove();
- equal( jQuery( "div", ibody ).length, 1, "Delete the div and check only one div left in IFrame" );
+ assert.equal( jQuery( "div", ibody ).length, 1, "Delete the div and check only one div left in IFrame" );
- equal( jQuery( "div", ibody ).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" );
+ assert.equal( jQuery( "div", ibody ).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" );
jQuery( "
", ibody ).append( "
cell
" ).appendTo( ibody );
jQuery( "table", ibody ).remove();
- equal( jQuery( "div", ibody ).length, 1, "Check for JS error on add and delete of a table in IFrame" );
+ assert.equal( jQuery( "div", ibody ).length, 1, "Check for JS error on add and delete of a table in IFrame" );
// using contents will get comments regular, text, and comment nodes
c = jQuery( "#nonnodes" ).contents().contents();
- equal( c.length, 1, "Check node,textnode,comment contents is just one" );
- equal( c[ 0 ].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );
+ assert.equal( c.length, 1, "Check node,textnode,comment contents is just one" );
+ assert.equal( c[ 0 ].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );
} );
-test( "sort direction", function() {
- expect( 12 );
+QUnit.test( "sort direction", function( assert ) {
+ assert.expect( 12 );
var elems = jQuery( "#ap, #select1 > *, #moretests > form" ),
methodDirections = {
@@ -696,50 +696,50 @@ test( "sort direction", function() {
jQuery.each( methodDirections, function( method, reversed ) {
var actual = elems[ method ]().get(),
forward = jQuery.uniqueSort( [].concat( actual ) );
- deepEqual( actual, reversed ? forward.reverse() : forward, "Correct sort direction for " + method );
+ assert.deepEqual( actual, reversed ? forward.reverse() : forward, "Correct sort direction for " + method );
} );
} );
-test( "add(String selector)", function() {
- expect( 2 );
+QUnit.test( "add(String selector)", function( assert ) {
+ assert.expect( 2 );
var divs;
- deepEqual(
+ assert.deepEqual(
jQuery( "#sndp" ).add( "#en" ).add( "#sap" ).toArray(),
q( "sndp", "en", "sap" ),
"Check elements from document"
);
divs = jQuery( "" ).add( "#sndp" );
- ok( divs[ 0 ].parentNode, "Sort with the disconnected node last (started with disconnected first)." );
+ assert.ok( divs[ 0 ].parentNode, "Sort with the disconnected node last (started with disconnected first)." );
} );
-test( "add(String selector, String context)", function() {
- expect( 1 );
+QUnit.test( "add(String selector, String context)", function( assert ) {
+ assert.expect( 1 );
- deepEqual(
+ assert.deepEqual(
jQuery( [] ).add( "div", "#nothiddendiv" ).toArray(),
q( "nothiddendivchild" ),
"Check elements from document"
);
} );
-test( "add(String html)", function() {
- expect( 3 );
+QUnit.test( "add(String html)", function( assert ) {
+ assert.expect( 3 );
var x,
divs = jQuery( "#sndp" ).add( "" );
- ok( !divs[ 1 ].parentNode, "Sort with the disconnected node last." );
+ assert.ok( !divs[ 1 ].parentNode, "Sort with the disconnected node last." );
x = jQuery( [] ).add( "
" ) ).text();
- equal(
+ assert.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.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(
+ 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( "" ) );
- 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( "" ) );
- equal(
+ assert.equal(
jQuery( "#nonnodes > i" ).length, 3, "Check node,textnode,comment wraps ok"
);
- equal(
+ assert.equal(
jQuery( "#nonnodes > i" ).text(),
j.text(),
"Check node,textnode,comment wraps doesn't hurt text"
@@ -67,52 +75,54 @@ function testWrap( val ) {
}
j = jQuery( "" ).wrap( val( "" ) );
- equal(
+ assert.equal(
j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label"
);
- equal(
+ assert.equal(
j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped"
);
for ( i in jQuery.cache ) {
cacheLength--;
}
- equal(
+ assert.equal(
cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)"
);
// Wrap an element containing a text node
j = jQuery( "" ).wrap( "
test
" );
- equal(
+ assert.equal(
j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element"
);
- equal(
+ 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( "
" ).children().wrap( "" );
- equal(
+ assert.equal(
j[ 0 ].parentNode.parentNode.childNodes.length,
1,
"There should only be one element wrapping."
);
- equal(
+ assert.equal(
j.length, 1, "There should only be one element (no cloning)."
);
- equal(
+ assert.equal(
j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph."
);
// Wrap an element with a jQuery set
j = jQuery( "" ).wrap( jQuery( "" ) );
- equal(
+ assert.equal(
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
);
// Wrap an element with a jQuery set and event
result = jQuery( "" ).on( "click", function() {
- ok( true, "Event triggered." );
+ assert.ok(
+ true, "Event triggered."
+ );
// Remove handlers on detached elements
result.off();
@@ -120,7 +130,7 @@ function testWrap( val ) {
} );
j = jQuery( "" ).wrap( result );
- equal(
+ assert.equal(
j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works."
);
@@ -128,21 +138,21 @@ function testWrap( val ) {
}
-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(
+ assert.equal(
i,
expectedIndex,
"Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")"
@@ -153,25 +163,28 @@ test( "wrap(Function) with index (#10177)", function() {
} );
} );
-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( "" );
targets.each( function() {
var $this = jQuery( this );
- ok( $this.parent().is( ".wrapper" ), "Check each elements parent is correct (.wrapper)" );
- equal(
+ 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;
@@ -179,22 +192,28 @@ test( "wrapAll(String)", function() {
p = jQuery( "#firstp,#first" )[ 0 ].parentNode;
result = jQuery( "#firstp,#first" ).wrapAll( "
" );
- equal(
+ assert.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(
+ 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"
);
- equal(
+ 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,
@@ -202,19 +221,25 @@ test( "wrapAll(Function)", function() {
return "
";
} );
- equal(
+ assert.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(
+ 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;
@@ -223,20 +248,22 @@ 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(
+ assert.strictEqual(
this, jQuery( "#firstp" )[ 0 ], "context must be the first found element"
);
- strictEqual(
+ assert.strictEqual(
index, undefined, "index argument should not be included in function execution"
);
} );
} );
-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,
@@ -244,19 +271,25 @@ test( "wrapAll(Function)", function() {
return "
";
} );
- equal(
+ assert.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(
+ 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;
@@ -265,21 +298,23 @@ 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(
+ assert.strictEqual(
this, jQuery( "#firstp" )[ 0 ], "context must be the first found element"
);
- strictEqual(
+ 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;
@@ -287,74 +322,80 @@ test( "wrapAll(Element)", function() {
p = jQuery( "#first" )[ 0 ].parentNode;
jQuery( "#firstp,#first" ).wrapAll( document.getElementById( "empty" ) );
- equal(
+ assert.equal(
jQuery( "#first" ).parent()[ 0 ], jQuery( "#firstp" ).parent()[ 0 ], "Same Parent"
);
- equal(
+ assert.equal(
jQuery( "#first" ).parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling"
);
- equal(
+ 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( "