" ).length, 0, "Ignore escaped html characters" );
});
-test("jQuery(tag-hyphenated elements) gh-1987", function() {
- expect( 17 );
+QUnit.test("jQuery(tag-hyphenated elements) gh-1987", function( assert ) {
+ assert.expect( 17 );
jQuery.each( "thead tbody tfoot colgroup caption tr th td".split(" "), function( i, name ) {
var j = jQuery("<" + name + "-d>" + name + "-d>");
- ok( j[0], "Create a tag-hyphenated elements" );
- ok( jQuery.nodeName(j[0], name.toUpperCase() + "-D"), "Tag-hyphenated element has expected node name" );
+ assert.ok( j[0], "Create a tag-hyphenated elements" );
+ assert.ok( jQuery.nodeName(j[0], name.toUpperCase() + "-D"), "Tag-hyphenated element has expected node name" );
});
var j = jQuery("
");
- ok( jQuery.nodeName(j[0], "TR-MULTIPLE-HYPHENS"), "Element with multiple hyphens in its tag has expected node name" );
+ assert.ok( jQuery.nodeName(j[0], "TR-MULTIPLE-HYPHENS"), "Element with multiple hyphens in its tag has expected node name" );
});
-test("jQuery('massive html #7990')", function() {
- expect( 3 );
+QUnit.test("jQuery('massive html #7990')", function( assert ) {
+ assert.expect( 3 );
var i,
li = "
very very very very large html string ",
@@ -617,59 +617,59 @@ test("jQuery('massive html #7990')", function() {
}
html[html.length] = "";
html = jQuery(html.join(""))[0];
- equal( html.nodeName.toLowerCase(), "ul");
- equal( html.firstChild.nodeName.toLowerCase(), "li");
- equal( html.childNodes.length, 30000 );
+ assert.equal( html.nodeName.toLowerCase(), "ul");
+ assert.equal( html.firstChild.nodeName.toLowerCase(), "li");
+ assert.equal( html.childNodes.length, 30000 );
});
-test("jQuery('html', context)", function() {
- expect(1);
+QUnit.test("jQuery('html', context)", function( assert ) {
+ assert.expect(1);
var $div = jQuery("
")[0],
$span = jQuery("
", $div);
- equal($span.length, 1, "verify a span created with a div context works, #1763");
+ assert.equal($span.length, 1, "verify a span created with a div context works, #1763");
});
-test("jQuery(selector, xml).text(str) - loaded via xml document", function() {
- expect(2);
+QUnit.test("jQuery(selector, xml).text(str) - loaded via xml document", function( assert ) {
+ assert.expect(2);
var xml = createDashboardXML(),
// tests for #1419 where ie was a problem
tab = jQuery("tab", xml).eq(0);
- equal( tab.text(), "blabla", "verify initial text correct" );
+ assert.equal( tab.text(), "blabla", "verify initial text correct" );
tab.text("newtext");
- equal( tab.text(), "newtext", "verify new text correct" );
+ assert.equal( tab.text(), "newtext", "verify new text correct" );
});
-test("end()", function() {
- expect(3);
- equal( "Yahoo", jQuery("#yahoo").parent().end().text(), "check for end" );
- ok( jQuery("#yahoo").end(), "check for end with nothing to end" );
+QUnit.test("end()", function( assert ) {
+ assert.expect(3);
+ assert.equal( "Yahoo", jQuery("#yahoo").parent().end().text(), "check for end" );
+ assert.ok( jQuery("#yahoo").end(), "check for end with nothing to end" );
var x = jQuery("#yahoo");
x.parent();
- equal( "Yahoo", jQuery("#yahoo").text(), "check for non-destructive behaviour" );
+ assert.equal( "Yahoo", jQuery("#yahoo").text(), "check for non-destructive behaviour" );
});
-test("length", function() {
- expect(1);
- equal( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" );
+QUnit.test("length", function( assert ) {
+ assert.expect(1);
+ assert.equal( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" );
});
-test("get()", function() {
- expect(1);
- deepEqual( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
+QUnit.test("get()", function( assert ) {
+ assert.expect(1);
+ assert.deepEqual( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
});
-test("toArray()", function() {
- expect(1);
- deepEqual( jQuery("#qunit-fixture p").toArray(),
+QUnit.test("toArray()", function( assert ) {
+ assert.expect(1);
+ assert.deepEqual( jQuery("#qunit-fixture p").toArray(),
q("firstp","ap","sndp","en","sap","first"),
"Convert jQuery object to an Array" );
});
-test("inArray()", function() {
- expect(19);
+QUnit.test("inArray()", function( assert ) {
+ assert.expect(19);
var selections = {
p: q("firstp", "sap", "ap", "first"),
@@ -691,33 +691,33 @@ test("inArray()", function() {
};
jQuery.each( tests, function( key, obj ) {
- equal( jQuery.inArray( obj.elem, selections[ key ] ), obj.index, "elem is in the array of selections of its tag" );
+ assert.equal( jQuery.inArray( obj.elem, selections[ key ] ), obj.index, "elem is in the array of selections of its tag" );
// Third argument (fromIndex)
- equal( !!~jQuery.inArray( obj.elem, selections[ key ], 5 ), false, "elem is NOT in the array of selections given a starting index greater than its position" );
- equal( !!~jQuery.inArray( obj.elem, selections[ key ], 1 ), true, "elem is in the array of selections given a starting index less than or equal to its position" );
- equal( !!~jQuery.inArray( obj.elem, selections[ key ], -3 ), true, "elem is in the array of selections given a negative index" );
+ assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], 5 ), false, "elem is NOT in the array of selections given a starting index greater than its position" );
+ assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], 1 ), true, "elem is in the array of selections given a starting index less than or equal to its position" );
+ assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], -3 ), true, "elem is in the array of selections given a negative index" );
});
jQuery.each( falseTests, function( key, elem ) {
- equal( !!~jQuery.inArray( elem, selections[ key ] ), false, "elem is NOT in the array of selections" );
+ assert.equal( !!~jQuery.inArray( elem, selections[ key ] ), false, "elem is NOT in the array of selections" );
});
});
-test("get(Number)", function() {
- expect(2);
- equal( jQuery("#qunit-fixture p").get(0), document.getElementById("firstp"), "Get A Single Element" );
- strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" );
+QUnit.test("get(Number)", function( assert ) {
+ assert.expect(2);
+ assert.equal( jQuery("#qunit-fixture p").get(0), document.getElementById("firstp"), "Get A Single Element" );
+ assert.strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" );
});
-test("get(-Number)",function() {
- expect(2);
- equal( jQuery("p").get(-1), document.getElementById("first"), "Get a single element with negative index" );
- strictEqual( jQuery("#firstp").get(-2), undefined, "Try get with index negative index larger then elements count" );
+QUnit.test("get(-Number)",function( assert ) {
+ assert.expect(2);
+ assert.equal( jQuery("p").get(-1), document.getElementById("first"), "Get a single element with negative index" );
+ assert.strictEqual( jQuery("#firstp").get(-2), undefined, "Try get with index negative index larger then elements count" );
});
-test("each(Function)", function() {
- expect(1);
+QUnit.test("each(Function)", function( assert ) {
+ assert.expect(1);
var div, pass, i;
div = jQuery("div");
@@ -728,40 +728,40 @@ test("each(Function)", function() {
pass = false;
}
}
- ok( pass, "Execute a function, Relative" );
+ assert.ok( pass, "Execute a function, Relative" );
});
-test("slice()", function() {
- expect(7);
+QUnit.test("slice()", function( assert ) {
+ assert.expect(7);
var $links = jQuery("#ap a");
- deepEqual( $links.slice(1,2).get(), q("groups"), "slice(1,2)" );
- deepEqual( $links.slice(1).get(), q("groups", "anchor1", "mark"), "slice(1)" );
- deepEqual( $links.slice(0,3).get(), q("google", "groups", "anchor1"), "slice(0,3)" );
- deepEqual( $links.slice(-1).get(), q("mark"), "slice(-1)" );
+ assert.deepEqual( $links.slice(1,2).get(), q("groups"), "slice(1,2)" );
+ assert.deepEqual( $links.slice(1).get(), q("groups", "anchor1", "mark"), "slice(1)" );
+ assert.deepEqual( $links.slice(0,3).get(), q("google", "groups", "anchor1"), "slice(0,3)" );
+ assert.deepEqual( $links.slice(-1).get(), q("mark"), "slice(-1)" );
- deepEqual( $links.eq(1).get(), q("groups"), "eq(1)" );
- deepEqual( $links.eq("2").get(), q("anchor1"), "eq('2')" );
- deepEqual( $links.eq(-1).get(), q("mark"), "eq(-1)" );
+ assert.deepEqual( $links.eq(1).get(), q("groups"), "eq(1)" );
+ assert.deepEqual( $links.eq("2").get(), q("anchor1"), "eq('2')" );
+ assert.deepEqual( $links.eq(-1).get(), q("mark"), "eq(-1)" );
});
-test("first()/last()", function() {
- expect(4);
+QUnit.test("first()/last()", function( assert ) {
+ assert.expect(4);
var $links = jQuery("#ap a"), $none = jQuery("asdf");
- deepEqual( $links.first().get(), q("google"), "first()" );
- deepEqual( $links.last().get(), q("mark"), "last()" );
+ assert.deepEqual( $links.first().get(), q("google"), "first()" );
+ assert.deepEqual( $links.last().get(), q("mark"), "last()" );
- deepEqual( $none.first().get(), [], "first() none" );
- deepEqual( $none.last().get(), [], "last() none" );
+ assert.deepEqual( $none.first().get(), [], "first() none" );
+ assert.deepEqual( $none.last().get(), [], "last() none" );
});
-test("map()", function() {
- expect( 2 );
+QUnit.test("map()", function( assert ) {
+ assert.expect( 2 );
- deepEqual(
+ assert.deepEqual(
jQuery("#ap").map(function() {
return jQuery( this ).find("a").get();
}).get(),
@@ -769,7 +769,7 @@ test("map()", function() {
"Array Map"
);
- deepEqual(
+ assert.deepEqual(
jQuery("#ap > a").map(function() {
return this.parentNode;
}).get(),
@@ -778,40 +778,40 @@ test("map()", function() {
);
});
-test("jQuery.map", function() {
- expect( 25 );
+QUnit.test("jQuery.map", function( assert ) {
+ assert.expect( 25 );
var i, label, result, callback;
result = jQuery.map( [ 3, 4, 5 ], function( v, k ) {
return k;
});
- equal( result.join(""), "012", "Map the keys from an array" );
+ assert.equal( result.join(""), "012", "Map the keys from an array" );
result = jQuery.map( [ 3, 4, 5 ], function( v ) {
return v;
});
- equal( result.join(""), "345", "Map the values from an array" );
+ assert.equal( result.join(""), "345", "Map the values from an array" );
result = jQuery.map( { a: 1, b: 2 }, function( v, k ) {
return k;
});
- equal( result.join(""), "ab", "Map the keys from an object" );
+ assert.equal( result.join(""), "ab", "Map the keys from an object" );
result = jQuery.map( { a: 1, b: 2 }, function( v ) {
return v;
});
- equal( result.join(""), "12", "Map the values from an object" );
+ assert.equal( result.join(""), "12", "Map the values from an object" );
result = jQuery.map( [ "a", undefined, null, "b" ], function( v ) {
return v;
});
- equal( result.join(""), "ab", "Array iteration does not include undefined/null results" );
+ assert.equal( result.join(""), "ab", "Array iteration does not include undefined/null results" );
result = jQuery.map( { a: "a", b: undefined, c: null, d: "b" }, function( v ) {
return v;
});
- equal( result.join(""), "ab", "Object iteration does not include undefined/null results" );
+ assert.equal( result.join(""), "ab", "Object iteration does not include undefined/null results" );
result = {
Zero: function() {},
@@ -819,7 +819,7 @@ test("jQuery.map", function() {
Two: function( a, b ) { a = a; b = b; }
};
callback = function( v, k ) {
- equal( k, "foo", label + "-argument function treated like object" );
+ assert.equal( k, "foo", label + "-argument function treated like object" );
};
for ( i in result ) {
label = i;
@@ -839,7 +839,7 @@ test("jQuery.map", function() {
"excess": 1
};
callback = function( v, k ) {
- equal( k, "length", "Object with " + label + " length treated like object" );
+ assert.equal( k, "length", "Object with " + label + " length treated like object" );
};
for ( i in result ) {
label = i;
@@ -855,7 +855,7 @@ test("jQuery.map", function() {
callback = function( v, k ) {
if ( result[ label ] ) {
delete result[ label ];
- equal( k, "0", label + " treated like array" );
+ assert.equal( k, "0", label + " treated like array" );
}
};
for ( i in result ) {
@@ -867,104 +867,104 @@ test("jQuery.map", function() {
jQuery.map( { length: 0 }, function() {
result = true;
});
- ok( !result, "length: 0 plain object treated like array" );
+ assert.ok( !result, "length: 0 plain object treated like array" );
result = false;
jQuery.map( document.getElementsByTagName("asdf"), function() {
result = true;
});
- ok( !result, "empty NodeList treated like array" );
+ assert.ok( !result, "empty NodeList treated like array" );
result = jQuery.map( Array(4), function( v, k ){
return k % 2 ? k : [k,k,k];
});
- equal( result.join(""), "00012223", "Array results flattened (#2616)" );
+ assert.equal( result.join(""), "00012223", "Array results flattened (#2616)" );
});
-test("jQuery.merge()", function() {
- expect( 10 );
+QUnit.test("jQuery.merge()", function( assert ) {
+ assert.expect( 10 );
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [], [] ),
[],
"Empty arrays"
);
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [ 1 ], [ 2 ] ),
[ 1, 2 ],
"Basic (single-element)"
);
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [ 1, 2 ], [ 3, 4 ] ),
[ 1, 2, 3, 4 ],
"Basic (multiple-element)"
);
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [ 1, 2 ], [] ),
[ 1, 2 ],
"Second empty"
);
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [], [ 1, 2 ] ),
[ 1, 2 ],
"First empty"
);
// Fixed at [5998], #3641
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [ -2, -1 ], [ 0, 1, 2 ] ),
[ -2, -1 , 0, 1, 2 ],
"Second array including a zero (falsy)"
);
// After fixing #5527
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [], [ null, undefined ] ),
[ null, undefined ],
"Second array including null and undefined values"
);
- deepEqual(
+ assert.deepEqual(
jQuery.merge( { length: 0 }, [ 1, 2 ] ),
{ length: 2, 0: 1, 1: 2 },
"First array like"
);
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [ 1, 2 ], { length: 1, 0: 3 } ),
[ 1, 2, 3 ],
"Second array like"
);
- deepEqual(
+ assert.deepEqual(
jQuery.merge( [], document.getElementById("lengthtest").getElementsByTagName("input") ),
[ document.getElementById("length"), document.getElementById("idTest") ],
"Second NodeList"
);
});
-test("jQuery.grep()", function() {
- expect(8);
+QUnit.test("jQuery.grep()", function( assert ) {
+ assert.expect(8);
var searchCriterion = function( value ) {
return value % 2 === 0;
};
- deepEqual( jQuery.grep( [], searchCriterion ), [], "Empty array" );
- deepEqual( jQuery.grep( new Array(4), searchCriterion ), [], "Sparse array" );
+ assert.deepEqual( jQuery.grep( [], searchCriterion ), [], "Empty array" );
+ assert.deepEqual( jQuery.grep( new Array(4), searchCriterion ), [], "Sparse array" );
- deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion ), [ 2, 4, 6 ], "Satisfying elements present" );
- deepEqual( jQuery.grep( [ 1, 3, 5, 7], searchCriterion ), [], "Satisfying elements absent" );
+ assert.deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion ), [ 2, 4, 6 ], "Satisfying elements present" );
+ assert.deepEqual( jQuery.grep( [ 1, 3, 5, 7], searchCriterion ), [], "Satisfying elements absent" );
- deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, true ), [ 1, 3, 5 ], "Satisfying elements present and grep inverted" );
- deepEqual( jQuery.grep( [ 1, 3, 5, 7], searchCriterion, true ), [1, 3, 5, 7], "Satisfying elements absent and grep inverted" );
+ assert.deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, true ), [ 1, 3, 5 ], "Satisfying elements present and grep inverted" );
+ assert.deepEqual( jQuery.grep( [ 1, 3, 5, 7], searchCriterion, true ), [1, 3, 5, 7], "Satisfying elements absent and grep inverted" );
- deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, false ), [ 2, 4, 6 ], "Satisfying elements present but grep explicitly uninverted" );
- deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion, false ), [], "Satisfying elements absent and grep explicitly uninverted" );
+ assert.deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, false ), [ 2, 4, 6 ], "Satisfying elements present but grep explicitly uninverted" );
+ assert.deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion, false ), [], "Satisfying elements absent and grep explicitly uninverted" );
});
-test("jQuery.extend(Object, Object)", function() {
- expect(28);
+QUnit.test("jQuery.extend(Object, Object)", function( assert ) {
+ assert.expect(28);
var empty, optionsWithLength, optionsWithDate, myKlass,
customObject, optionsWithCustomObject, MyNumber, ret,
@@ -982,33 +982,33 @@ test("jQuery.extend(Object, Object)", function() {
nestedarray = { "arr": arr };
jQuery.extend(settings, options);
- deepEqual( settings, merged, "Check if extended: settings must be extended" );
- deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
+ assert.deepEqual( settings, merged, "Check if extended: settings must be extended" );
+ assert.deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
jQuery.extend(settings, null, options);
- deepEqual( settings, merged, "Check if extended: settings must be extended" );
- deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
+ assert.deepEqual( settings, merged, "Check if extended: settings must be extended" );
+ assert.deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
jQuery.extend(true, deep1, deep2);
- deepEqual( deep1["foo"], deepmerged["foo"], "Check if foo: settings must be extended" );
- deepEqual( deep2["foo"], deep2copy["foo"], "Check if not deep2: options must not be modified" );
- equal( deep1["foo2"], document, "Make sure that a deep clone was not attempted on the document" );
+ assert.deepEqual( deep1["foo"], deepmerged["foo"], "Check if foo: settings must be extended" );
+ assert.deepEqual( deep2["foo"], deep2copy["foo"], "Check if not deep2: options must not be modified" );
+ assert.equal( deep1["foo2"], document, "Make sure that a deep clone was not attempted on the document" );
- ok( jQuery.extend(true, {}, nestedarray)["arr"] !== arr, "Deep extend of object must clone child array" );
+ assert.ok( jQuery.extend(true, {}, nestedarray)["arr"] !== arr, "Deep extend of object must clone child array" );
// #5991
- ok( jQuery.isArray( jQuery.extend(true, { "arr": {} }, nestedarray)["arr"] ), "Cloned array have to be an Array" );
- ok( jQuery.isPlainObject( jQuery.extend(true, { "arr": arr }, { "arr": {} })["arr"] ), "Cloned object have to be an plain object" );
+ assert.ok( jQuery.isArray( jQuery.extend(true, { "arr": {} }, nestedarray)["arr"] ), "Cloned array have to be an Array" );
+ assert.ok( jQuery.isPlainObject( jQuery.extend(true, { "arr": arr }, { "arr": {} })["arr"] ), "Cloned object have to be an plain object" );
empty = {};
optionsWithLength = { "foo": { "length": -1 } };
jQuery.extend(true, empty, optionsWithLength);
- deepEqual( empty["foo"], optionsWithLength["foo"], "The length property must copy correctly" );
+ assert.deepEqual( empty["foo"], optionsWithLength["foo"], "The length property must copy correctly" );
empty = {};
optionsWithDate = { "foo": { "date": new Date() } };
jQuery.extend(true, empty, optionsWithDate);
- deepEqual( empty["foo"], optionsWithDate["foo"], "Dates copy correctly" );
+ assert.deepEqual( empty["foo"], optionsWithDate["foo"], "Dates copy correctly" );
/** @constructor */
myKlass = function() {};
@@ -1016,50 +1016,50 @@ test("jQuery.extend(Object, Object)", function() {
optionsWithCustomObject = { "foo": { "date": customObject } };
empty = {};
jQuery.extend(true, empty, optionsWithCustomObject);
- ok( empty["foo"] && empty["foo"]["date"] === customObject, "Custom objects copy correctly (no methods)" );
+ assert.ok( empty["foo"] && empty["foo"]["date"] === customObject, "Custom objects copy correctly (no methods)" );
// Makes the class a little more realistic
myKlass.prototype = { "someMethod": function(){} };
empty = {};
jQuery.extend(true, empty, optionsWithCustomObject);
- ok( empty["foo"] && empty["foo"]["date"] === customObject, "Custom objects copy correctly" );
+ assert.ok( empty["foo"] && empty["foo"]["date"] === customObject, "Custom objects copy correctly" );
MyNumber = Number;
ret = jQuery.extend(true, { "foo": 4 }, { "foo": new MyNumber(5) } );
- ok( parseInt(ret.foo, 10) === 5, "Wrapped numbers copy correctly" );
+ assert.ok( parseInt(ret.foo, 10) === 5, "Wrapped numbers copy correctly" );
nullUndef;
nullUndef = jQuery.extend({}, options, { "xnumber2": null });
- ok( nullUndef["xnumber2"] === null, "Check to make sure null values are copied");
+ assert.ok( nullUndef["xnumber2"] === null, "Check to make sure null values are copied");
nullUndef = jQuery.extend({}, options, { "xnumber2": undefined });
- ok( nullUndef["xnumber2"] === options["xnumber2"], "Check to make sure undefined values are not copied");
+ assert.ok( nullUndef["xnumber2"] === options["xnumber2"], "Check to make sure undefined values are not copied");
nullUndef = jQuery.extend({}, options, { "xnumber0": null });
- ok( nullUndef["xnumber0"] === null, "Check to make sure null values are inserted");
+ assert.ok( nullUndef["xnumber0"] === null, "Check to make sure null values are inserted");
target = {};
recursive = { foo:target, bar:5 };
jQuery.extend(true, target, recursive);
- deepEqual( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
+ assert.deepEqual( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
ret = jQuery.extend(true, { foo: [] }, { foo: [0] } ); // 1907
- equal( ret.foo.length, 1, "Check to make sure a value with coercion 'false' copies over when necessary to fix #1907" );
+ assert.equal( ret.foo.length, 1, "Check to make sure a value with coercion 'false' copies over when necessary to fix #1907" );
ret = jQuery.extend(true, { foo: "1,2,3" }, { foo: [1, 2, 3] } );
- ok( typeof ret.foo !== "string", "Check to make sure values equal with coercion (but not actually equal) overwrite correctly" );
+ assert.ok( typeof ret.foo !== "string", "Check to make sure values equal with coercion (but not actually equal) overwrite correctly" );
ret = jQuery.extend(true, { foo:"bar" }, { foo:null } );
- ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" );
+ assert.ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" );
obj = { foo:null };
jQuery.extend(true, obj, { foo:"notnull" } );
- equal( obj.foo, "notnull", "Make sure a null value can be overwritten" );
+ assert.equal( obj.foo, "notnull", "Make sure a null value can be overwritten" );
function func() {}
jQuery.extend(func, { key: "value" } );
- equal( func.key, "value", "Verify a function can be extended" );
+ assert.equal( func.key, "value", "Verify a function can be extended" );
defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" };
defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" };
@@ -1070,14 +1070,14 @@ test("jQuery.extend(Object, Object)", function() {
merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
settings = jQuery.extend({}, defaults, options1, options2);
- deepEqual( settings, merged2, "Check if extended: settings must be extended" );
- deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
- deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" );
- deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
+ assert.deepEqual( settings, merged2, "Check if extended: settings must be extended" );
+ assert.deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
+ assert.deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" );
+ assert.deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
});
-test("jQuery.extend(true,{},{a:[], o:{}}); deep copy with array, followed by object", function() {
- expect(2);
+QUnit.test("jQuery.extend(true,{},{a:[], o:{}}); deep copy with array, followed by object", function( assert ) {
+ assert.expect(2);
var result, initial = {
// This will make "copyIsArray" true
@@ -1093,12 +1093,12 @@ test("jQuery.extend(true,{},{a:[], o:{}}); deep copy with array, followed by obj
result = jQuery.extend( true, {}, initial );
- deepEqual( result, initial, "The [result] and [initial] have equal shape and values" );
- ok( !jQuery.isArray( result.object ), "result.object wasn't paved with an empty array" );
+ assert.deepEqual( result, initial, "The [result] and [initial] have equal shape and values" );
+ assert.ok( !jQuery.isArray( result.object ), "result.object wasn't paved with an empty array" );
});
-test("jQuery.each(Object,Function)", function() {
- expect( 23 );
+QUnit.test("jQuery.each(Object,Function)", function( assert ) {
+ assert.expect( 23 );
var i, label, seen, callback;
@@ -1106,13 +1106,13 @@ test("jQuery.each(Object,Function)", function() {
jQuery.each( [ 3, 4, 5 ], function( k, v ) {
seen[ k ] = v;
});
- deepEqual( seen, { "0": 3, "1": 4, "2": 5 }, "Array iteration" );
+ assert.deepEqual( seen, { "0": 3, "1": 4, "2": 5 }, "Array iteration" );
seen = {};
jQuery.each( { name: "name", lang: "lang" }, function( k, v ) {
seen[ k ] = v;
});
- deepEqual( seen, { name: "name", lang: "lang" }, "Object iteration" );
+ assert.deepEqual( seen, { name: "name", lang: "lang" }, "Object iteration" );
seen = [];
jQuery.each( [ 1, 2, 3 ], function( k, v ) {
@@ -1121,14 +1121,14 @@ test("jQuery.each(Object,Function)", function() {
return false;
}
});
- deepEqual( seen, [ 1, 2 ] , "Broken array iteration" );
+ assert.deepEqual( seen, [ 1, 2 ] , "Broken array iteration" );
seen = [];
jQuery.each( {"a": 1, "b": 2,"c": 3 }, function( k, v ) {
seen.push( v );
return false;
});
- deepEqual( seen, [ 1 ], "Broken object iteration" );
+ assert.deepEqual( seen, [ 1 ], "Broken object iteration" );
seen = {
Zero: function() {},
@@ -1136,7 +1136,7 @@ test("jQuery.each(Object,Function)", function() {
Two: function( a, b ) { a = a; b = b; }
};
callback = function( k ) {
- equal( k, "foo", label + "-argument function treated like object" );
+ assert.equal( k, "foo", label + "-argument function treated like object" );
};
for ( i in seen ) {
label = i;
@@ -1156,7 +1156,7 @@ test("jQuery.each(Object,Function)", function() {
"excess": 1
};
callback = function( k ) {
- equal( k, "length", "Object with " + label + " length treated like object" );
+ assert.equal( k, "length", "Object with " + label + " length treated like object" );
};
for ( i in seen ) {
label = i;
@@ -1172,7 +1172,7 @@ test("jQuery.each(Object,Function)", function() {
callback = function( k ) {
if ( seen[ label ] ) {
delete seen[ label ];
- equal( k, "0", label + " treated like array" );
+ assert.equal( k, "0", label + " treated like array" );
return false;
}
};
@@ -1185,37 +1185,37 @@ test("jQuery.each(Object,Function)", function() {
jQuery.each( { length: 0 }, function() {
seen = true;
});
- ok( !seen, "length: 0 plain object treated like array" );
+ assert.ok( !seen, "length: 0 plain object treated like array" );
seen = false;
jQuery.each( document.getElementsByTagName("asdf"), function() {
seen = true;
});
- ok( !seen, "empty NodeList treated like array" );
+ assert.ok( !seen, "empty NodeList treated like array" );
i = 0;
jQuery.each( document.styleSheets, function() {
i++;
});
- equal( i, document.styleSheets.length, "Iteration over document.styleSheets" );
+ assert.equal( i, document.styleSheets.length, "Iteration over document.styleSheets" );
});
-test("jQuery.each/map(undefined/null,Function)", function() {
- expect( 1 );
+QUnit.test("jQuery.each/map(undefined/null,Function)", function( assert ) {
+ assert.expect( 1 );
try {
jQuery.each( undefined, jQuery.noop );
jQuery.each( null, jQuery.noop );
jQuery.map( undefined, jQuery.noop );
jQuery.map( null, jQuery.noop );
- ok( true, "jQuery.each/map( undefined/null, function() {} );" );
+ assert.ok( true, "jQuery.each/map( undefined/null, function() {} );" );
} catch ( e ) {
- ok( false, "each/map must accept null and undefined values" );
+ assert.ok( false, "each/map must accept null and undefined values" );
}
});
-test( "JIT compilation does not interfere with length retrieval (gh-2145)", function() {
- expect( 4 );
+QUnit.test( "JIT compilation does not interfere with length retrieval (gh-2145)", function( assert ) {
+ assert.expect( 4 );
var i;
@@ -1228,73 +1228,73 @@ test( "JIT compilation does not interfere with length retrieval (gh-2145)", func
i = 0;
jQuery.each( { 1: "1", 2: "2", 3: "3" }, function( index ) {
- equal( ++i, index, "Iteration over object with solely " +
+ assert.equal( ++i, index, "Iteration over object with solely " +
"numeric indices (gh-2145 JIT iOS 8 bug)" );
});
- equal( i, 3, "Iteration over object with solely " +
+ assert.equal( i, 3, "Iteration over object with solely " +
"numeric indices (gh-2145 JIT iOS 8 bug)" );
});
-test("jQuery.makeArray", function(){
- expect(15);
+QUnit.test("jQuery.makeArray", function( assert ){
+ assert.expect(15);
- equal( jQuery.makeArray(jQuery("html>*"))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" );
+ assert.equal( jQuery.makeArray(jQuery("html>*"))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" );
- equal( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );
+ assert.equal( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );
- equal( (function() { return jQuery.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );
+ assert.equal( (function() { return jQuery.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );
- equal( jQuery.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" );
+ assert.equal( jQuery.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" );
- equal( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" );
+ assert.equal( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" );
- equal( jQuery.makeArray( 0 )[0], 0 , "Pass makeArray a number" );
+ assert.equal( jQuery.makeArray( 0 )[0], 0 , "Pass makeArray a number" );
- equal( jQuery.makeArray( "foo" )[0], "foo", "Pass makeArray a string" );
+ assert.equal( jQuery.makeArray( "foo" )[0], "foo", "Pass makeArray a string" );
- equal( jQuery.makeArray( true )[0].constructor, Boolean, "Pass makeArray a boolean" );
+ assert.equal( jQuery.makeArray( true )[0].constructor, Boolean, "Pass makeArray a boolean" );
- equal( jQuery.makeArray( document.createElement("div") )[0].nodeName.toUpperCase(), "DIV", "Pass makeArray a single node" );
+ assert.equal( jQuery.makeArray( document.createElement("div") )[0].nodeName.toUpperCase(), "DIV", "Pass makeArray a single node" );
- equal( jQuery.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" );
+ assert.equal( jQuery.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" );
- ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "Pass makeArray a childNodes array" );
+ assert.ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "Pass makeArray a childNodes array" );
// function, is tricky as it has length
- equal( jQuery.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );
+ assert.equal( jQuery.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );
//window, also has length
- equal( jQuery.makeArray(window)[0], window, "Pass makeArray the window" );
+ assert.equal( jQuery.makeArray(window)[0], window, "Pass makeArray the window" );
- equal( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );
+ assert.equal( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );
// Some nodes inherit traits of nodelists
- ok( jQuery.makeArray(document.getElementById("form")).length >= 13,
+ assert.ok( jQuery.makeArray(document.getElementById("form")).length >= 13,
"Pass makeArray a form (treat as elements)" );
});
-test("jQuery.inArray", function(){
- expect(3);
+QUnit.test("jQuery.inArray", function( assert ){
+ assert.expect(3);
- equal( jQuery.inArray( 0, false ), -1 , "Search in 'false' as array returns -1 and doesn't throw exception" );
+ assert.equal( jQuery.inArray( 0, false ), -1 , "Search in 'false' as array returns -1 and doesn't throw exception" );
- equal( jQuery.inArray( 0, null ), -1 , "Search in 'null' as array returns -1 and doesn't throw exception" );
+ assert.equal( jQuery.inArray( 0, null ), -1 , "Search in 'null' as array returns -1 and doesn't throw exception" );
- equal( jQuery.inArray( 0, undefined ), -1 , "Search in 'undefined' as array returns -1 and doesn't throw exception" );
+ assert.equal( jQuery.inArray( 0, undefined ), -1 , "Search in 'undefined' as array returns -1 and doesn't throw exception" );
});
-test("jQuery.isEmptyObject", function(){
- expect(2);
+QUnit.test("jQuery.isEmptyObject", function( assert ){
+ assert.expect(2);
- equal(true, jQuery.isEmptyObject({}), "isEmptyObject on empty object literal" );
- equal(false, jQuery.isEmptyObject({a:1}), "isEmptyObject on non-empty object literal" );
+ assert.equal(true, jQuery.isEmptyObject({}), "isEmptyObject on empty object literal" );
+ assert.equal(false, jQuery.isEmptyObject({a:1}), "isEmptyObject on non-empty object literal" );
// What about this ?
// equal(true, jQuery.isEmptyObject(null), "isEmptyObject on null" );
});
-test("jQuery.proxy", function(){
- expect( 9 );
+QUnit.test("jQuery.proxy", function( assert ){
+ assert.expect( 9 );
var test2, test3, test4, fn, cb,
test = function(){ equal( this, thisObject, "Make sure that scope is set properly." ); },
@@ -1310,7 +1310,7 @@ test("jQuery.proxy", function(){
jQuery.proxy( thisObject, "method" )();
// Make sure it doesn't freak out
- equal( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." );
+ assert.equal( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." );
// Partial application
test2 = function( a ){ equal( a, "pre-applied", "Ensure arguments can be pre-applied." ); };
@@ -1326,60 +1326,60 @@ test("jQuery.proxy", function(){
// jQuery 1.9 improved currying with `this` object
fn = function() {
- equal( Array.prototype.join.call( arguments, "," ), "arg1,arg2,arg3", "args passed" );
- equal( this.foo, "bar", "this-object passed" );
+ assert.equal( Array.prototype.join.call( arguments, "," ), "arg1,arg2,arg3", "args passed" );
+ assert.equal( this.foo, "bar", "this-object passed" );
};
cb = jQuery.proxy( fn, null, "arg1", "arg2" );
cb.call( thisObject, "arg3" );
});
-test("jQuery.parseHTML", function() {
- expect( 23 );
+QUnit.test("jQuery.parseHTML", function( assert ) {
+ assert.expect( 23 );
var html, nodes;
- deepEqual( jQuery.parseHTML(), [], "Without arguments" );
- deepEqual( jQuery.parseHTML( undefined ), [], "Undefined" );
- deepEqual( jQuery.parseHTML( null ), [], "Null" );
- deepEqual( jQuery.parseHTML( false ), [], "Boolean false" );
- deepEqual( jQuery.parseHTML( 0 ), [], "Zero" );
- deepEqual( jQuery.parseHTML( true ), [], "Boolean true" );
- deepEqual( jQuery.parseHTML( 42 ), [], "Positive number" );
- deepEqual( jQuery.parseHTML( "" ), [], "Empty string" );
- throws(function() {
+ assert.deepEqual( jQuery.parseHTML(), [], "Without arguments" );
+ assert.deepEqual( jQuery.parseHTML( undefined ), [], "Undefined" );
+ assert.deepEqual( jQuery.parseHTML( null ), [], "Null" );
+ assert.deepEqual( jQuery.parseHTML( false ), [], "Boolean false" );
+ assert.deepEqual( jQuery.parseHTML( 0 ), [], "Zero" );
+ assert.deepEqual( jQuery.parseHTML( true ), [], "Boolean true" );
+ assert.deepEqual( jQuery.parseHTML( 42 ), [], "Positive number" );
+ assert.deepEqual( jQuery.parseHTML( "" ), [], "Empty string" );
+ assert.throws(function() {
jQuery.parseHTML( "
", document.getElementById("form") );
}, "Passing an element as the context raises an exception (context should be a document)");
nodes = jQuery.parseHTML( jQuery("body")[0].innerHTML );
- ok( nodes.length > 4, "Parse a large html string" );
- equal( jQuery.type( nodes ), "array", "parseHTML returns an array rather than a nodelist" );
+ assert.ok( nodes.length > 4, "Parse a large html string" );
+ assert.equal( jQuery.type( nodes ), "array", "parseHTML returns an array rather than a nodelist" );
html = "";
- equal( jQuery.parseHTML( html ).length, 0, "Ignore scripts by default" );
- equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve scripts when requested" );
+ assert.equal( jQuery.parseHTML( html ).length, 0, "Ignore scripts by default" );
+ assert.equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve scripts when requested" );
html += "
";
- equal( jQuery.parseHTML( html )[0].nodeName.toLowerCase(), "div", "Preserve non-script nodes" );
- equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve script position");
+ assert.equal( jQuery.parseHTML( html )[0].nodeName.toLowerCase(), "div", "Preserve non-script nodes" );
+ assert.equal( jQuery.parseHTML( html, true )[0].nodeName.toLowerCase(), "script", "Preserve script position");
- equal( jQuery.parseHTML("text")[0].nodeType, 3, "Parsing text returns a text node" );
- equal( jQuery.parseHTML( "\t
" )[0].nodeValue, "\t", "Preserve leading whitespace" );
+ assert.equal( jQuery.parseHTML("text")[0].nodeType, 3, "Parsing text returns a text node" );
+ assert.equal( jQuery.parseHTML( "\t
" )[0].nodeValue, "\t", "Preserve leading whitespace" );
- equal( jQuery.parseHTML("
")[0].nodeType, 3, "Leading spaces are treated as text nodes (#11290)" );
+ assert.equal( jQuery.parseHTML("
")[0].nodeType, 3, "Leading spaces are treated as text nodes (#11290)" );
html = jQuery.parseHTML( "
test div
" );
- equal( html[ 0 ].parentNode.nodeType, 11, "parentNode should be documentFragment" );
- equal( html[ 0 ].innerHTML, "test div", "Content should be preserved" );
+ assert.equal( html[ 0 ].parentNode.nodeType, 11, "parentNode should be documentFragment" );
+ assert.equal( html[ 0 ].innerHTML, "test div", "Content should be preserved" );
- equal( jQuery.parseHTML("
").length, 1, "Incorrect html-strings should not break anything" );
- equal( jQuery.parseHTML(" ")[ 1 ].parentNode.nodeType, 11,
+ assert.equal( jQuery.parseHTML("").length, 1, "Incorrect html-strings should not break anything" );
+ assert.equal( jQuery.parseHTML(" ")[ 1 ].parentNode.nodeType, 11,
"parentNode should be documentFragment for wrapMap (variable in manipulation module) elements too" );
- ok( jQuery.parseHTML("<#if> This is a test.
<#/if>") || true, "Garbage input should not cause error" );
+ assert.ok( jQuery.parseHTML("<#if>
This is a test.
<#/if>") || true, "Garbage input should not cause error" );
});
if ( jQuery.support.createHTMLDocument ) {
- asyncTest("jQuery.parseHTML", function() {
+ QUnit.asyncTest("jQuery.parseHTML", function( assert ) {
expect ( 1 );
Globals.register("parseHTMLError");
@@ -1388,69 +1388,69 @@ if ( jQuery.support.createHTMLDocument ) {
jQuery.parseHTML( "
" );
window.setTimeout(function() {
- start();
- equal( window.parseHTMLError, false, "onerror eventhandler has not been called." );
+ QUnit.start();
+ assert.equal( window.parseHTMLError, false, "onerror eventhandler has not been called." );
}, 2000);
});
}
-test("jQuery.parseJSON", function() {
- expect( 20 );
+QUnit.test("jQuery.parseJSON", function( assert ) {
+ assert.expect( 20 );
- strictEqual( jQuery.parseJSON( null ), null, "primitive null" );
- strictEqual( jQuery.parseJSON("0.88"), 0.88, "Number" );
- strictEqual(
+ assert.strictEqual( jQuery.parseJSON( null ), null, "primitive null" );
+ assert.strictEqual( jQuery.parseJSON("0.88"), 0.88, "Number" );
+ assert.strictEqual(
jQuery.parseJSON("\" \\\" \\\\ \\/ \\b \\f \\n \\r \\t \\u007E \\u263a \""),
" \" \\ / \b \f \n \r \t ~ \u263A ",
"String escapes"
);
- deepEqual( jQuery.parseJSON("{}"), {}, "Empty object" );
- deepEqual( jQuery.parseJSON("{\"test\":1}"), { "test": 1 }, "Plain object" );
- deepEqual( jQuery.parseJSON("[0]"), [ 0 ], "Simple array" );
+ assert.deepEqual( jQuery.parseJSON("{}"), {}, "Empty object" );
+ assert.deepEqual( jQuery.parseJSON("{\"test\":1}"), { "test": 1 }, "Plain object" );
+ assert.deepEqual( jQuery.parseJSON("[0]"), [ 0 ], "Simple array" );
- deepEqual(
+ assert.deepEqual(
jQuery.parseJSON("[ \"string\", -4.2, 2.7180e0, 3.14E-1, {}, [], true, false, null ]"),
[ "string", -4.2, 2.718, 0.314, {}, [], true, false, null ],
"Array of all data types"
);
- deepEqual(
+ assert.deepEqual(
jQuery.parseJSON( "{ \"string\": \"\", \"number\": 4.2e+1, \"object\": {}," +
"\"array\": [[]], \"boolean\": [ true, false ], \"null\": null }"),
{ string: "", number: 42, object: {}, array: [[]], "boolean": [ true, false ], "null": null },
"Dictionary of all data types"
);
- deepEqual( jQuery.parseJSON("\n{\"test\":1}\t"), { "test": 1 },
+ assert.deepEqual( jQuery.parseJSON("\n{\"test\":1}\t"), { "test": 1 },
"Leading and trailing whitespace are ignored" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON();
}, null, "Undefined raises an error" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON( "" );
}, null, "Empty string raises an error" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("''");
}, null, "Single-quoted string raises an error" );
/*
// Broken on IE8
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("\" \\a \"");
}, null, "Invalid string escape raises an error" );
// Broken on IE8, Safari 5.1 Windows
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("\"\t\"");
}, null, "Unescaped control character raises an error" );
// Broken on IE8
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON(".123");
}, null, "Number with no integer component raises an error" );
*/
- throws(function() {
+ assert.throws(function() {
var result = jQuery.parseJSON("0101");
// Support: IE9+
@@ -1459,63 +1459,63 @@ test("jQuery.parseJSON", function() {
throw new Error("close enough");
}
}, null, "Leading-zero number raises an error or is parsed as decimal" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("{a:1}");
}, null, "Unquoted property raises an error" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("{'a':1}");
}, null, "Single-quoted property raises an error" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("[,]");
}, null, "Array element elision raises an error" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("{},[]");
}, null, "Comma expression raises an error" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("[]\n,{}");
}, null, "Newline-containing comma expression raises an error" );
- throws(function() {
+ assert.throws(function() {
jQuery.parseJSON("\"\"\n\"\"");
}, null, "Automatic semicolon insertion raises an error" );
- strictEqual( jQuery.parseJSON([ 0 ]), 0, "Input cast to string" );
+ assert.strictEqual( jQuery.parseJSON([ 0 ]), 0, "Input cast to string" );
});
-test("jQuery.parseXML", function(){
- expect( 8 );
+QUnit.test("jQuery.parseXML", function( assert ){
+ assert.expect( 8 );
var xml, tmp;
try {
xml = jQuery.parseXML( "
A well-formed xml string
" );
tmp = xml.getElementsByTagName( "p" )[ 0 ];
- ok( !!tmp, "
present in document" );
+ assert.ok( !!tmp, "
present in document" );
tmp = tmp.getElementsByTagName( "b" )[ 0 ];
- ok( !!tmp, " present in document" );
- strictEqual( tmp.childNodes[ 0 ].nodeValue, "well-formed", " text is as expected" );
+ assert.ok( !!tmp, " present in document" );
+ assert.strictEqual( tmp.childNodes[ 0 ].nodeValue, "well-formed", " text is as expected" );
} catch (e) {
- strictEqual( e, undefined, "unexpected error" );
+ assert.strictEqual( e, undefined, "unexpected error" );
}
try {
xml = jQuery.parseXML( "
Not a <well-formed xml string
" );
- ok( false, "invalid xml not detected" );
+ assert.ok( false, "invalid xml not detected" );
} catch( e ) {
- strictEqual( e.message, "Invalid XML:
Not a <well-formed xml string
", "invalid xml detected" );
+ assert.strictEqual( e.message, "Invalid XML:
Not a <well-formed xml string
", "invalid xml detected" );
}
try {
xml = jQuery.parseXML( "" );
- strictEqual( xml, null, "empty string => null document" );
+ assert.strictEqual( xml, null, "empty string => null document" );
xml = jQuery.parseXML();
- strictEqual( xml, null, "undefined string => null document" );
+ assert.strictEqual( xml, null, "undefined string => null document" );
xml = jQuery.parseXML( null );
- strictEqual( xml, null, "null string => null document" );
+ assert.strictEqual( xml, null, "null string => null document" );
xml = jQuery.parseXML( true );
- strictEqual( xml, null, "non-string => null document" );
+ assert.strictEqual( xml, null, "non-string => null document" );
} catch( e ) {
- ok( false, "empty input throws exception" );
+ assert.ok( false, "empty input throws exception" );
}
});
-test("jQuery.camelCase()", function() {
+QUnit.test("jQuery.camelCase()", function( assert ) {
var tests = {
"foo-bar": "fooBar",
@@ -1527,47 +1527,59 @@ test("jQuery.camelCase()", function() {
"-ms-take": "msTake"
};
- expect(7);
+ assert.expect(7);
jQuery.each( tests, function( key, val ) {
- equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val );
+ assert.equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val );
});
});
-testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/cc_on.html", function( cc_on, errors, $ ) {
- expect( 3 );
- ok( true, "JScript conditional compilation " + ( cc_on ? "supported" : "not supported" ) );
- deepEqual( errors, [], "No errors" );
- ok( $(), "jQuery executes" );
-});
+testIframeWithCallback(
+ "Conditional compilation compatibility (#13274)",
+ "core/cc_on.html",
+ function( cc_on, errors, $, assert ) {
+ assert.expect( 3 );
+ assert.ok( true, "JScript conditional compilation " + ( cc_on ? "supported" : "not supported" ) );
+ assert.deepEqual( errors, [], "No errors" );
+ assert.ok( $(), "jQuery executes" );
+ }
+);
// iOS7 doesn't fire the load event if the long-loading iframe gets its source reset to about:blank.
// This makes this test fail but it doesn't seem to cause any real-life problems so blacklisting
// this test there is preferred to complicating the hard-to-test core/ready code further.
if ( !/iphone os 7_/i.test( navigator.userAgent ) ) {
- testIframeWithCallback( "document ready when jQuery loaded asynchronously (#13655)", "core/dynamic_ready.html", function( ready ) {
- expect( 1 );
- equal( true, ready, "document ready correctly fired when jQuery is loaded after DOMContentLoaded" );
- });
+ testIframeWithCallback(
+ "document ready when jQuery loaded asynchronously (#13655)",
+ "core/dynamic_ready.html",
+ function( ready, assert ) {
+ assert.expect( 1 );
+ assert.equal( true, ready, "document ready correctly fired when jQuery is loaded after DOMContentLoaded" );
+ }
+ );
}
-testIframeWithCallback( "Tolerating alias-masked DOM properties (#14074)", "core/aliased.html",
- function( errors ) {
- expect( 1 );
- deepEqual( errors, [], "jQuery loaded" );
+testIframeWithCallback(
+ "Tolerating alias-masked DOM properties (#14074)",
+ "core/aliased.html",
+ function( errors, assert ) {
+ assert.expect( 1 );
+ assert.deepEqual( errors, [], "jQuery loaded" );
}
);
-testIframeWithCallback( "Don't call window.onready (#14802)", "core/onready.html",
- function( error ) {
- expect( 1 );
- equal( error, false, "no call to user-defined onready" );
+testIframeWithCallback(
+ "Don't call window.onready (#14802)",
+ "core/onready.html",
+ function( error, assert ) {
+ assert.expect( 1 );
+ assert.equal( error, false, "no call to user-defined onready" );
}
);
-test( "Iterability of jQuery objects (gh-1693)", function() {
+QUnit.test( "Iterability of jQuery objects (gh-1693)", function( assert ) {
/* jshint unused: false */
- expect( 1 );
+ assert.expect( 1 );
var i, elem, result;
@@ -1579,8 +1591,8 @@ test( "Iterability of jQuery objects (gh-1693)", function() {
try {
eval( "for ( i of elem ) { result += i.nodeName; }" );
} catch ( e ) {}
- equal( result, "DIVSPANA", "for-of works on jQuery objects" );
+ assert.equal( result, "DIVSPANA", "for-of works on jQuery objects" );
} else {
- ok( true, "The browser doesn't support Symbols" );
+ assert.ok( true, "The browser doesn't support Symbols" );
}
} );
diff --git a/test/unit/css.js b/test/unit/css.js
index 1ec7e8aab..c28afd6fa 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -1,35 +1,35 @@
if ( jQuery.css ) {
-module("css", { teardown: moduleTeardown });
+QUnit.module("css", { teardown: moduleTeardown });
-test("css(String|Hash)", function() {
- expect( 42 );
+QUnit.test("css(String|Hash)", function( assert ) {
+ assert.expect( 42 );
- equal( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\"" );
+ assert.equal( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\"" );
var $child, div, div2, width, height, child, prctval, checkval, old;
$child = jQuery("#nothiddendivchild").css({ "width": "20%", "height": "20%" });
- notEqual( $child.css("width"), "20px", "Retrieving a width percentage on the child of a hidden div returns percentage" );
- notEqual( $child.css("height"), "20px", "Retrieving a height percentage on the child of a hidden div returns percentage" );
+ assert.notEqual( $child.css("width"), "20px", "Retrieving a width percentage on the child of a hidden div returns percentage" );
+ assert.notEqual( $child.css("height"), "20px", "Retrieving a height percentage on the child of a hidden div returns percentage" );
div = jQuery( "
" );
// These should be "auto" (or some better value)
// temporarily provide "0px" for backwards compat
- equal( div.css("width"), "0px", "Width on disconnected node." );
- equal( div.css("height"), "0px", "Height on disconnected node." );
+ assert.equal( div.css("width"), "0px", "Width on disconnected node." );
+ assert.equal( div.css("height"), "0px", "Height on disconnected node." );
div.css({ "width": 4, "height": 4 });
- equal( div.css("width"), "4px", "Width on disconnected node." );
- equal( div.css("height"), "4px", "Height on disconnected node." );
+ assert.equal( div.css("width"), "4px", "Width on disconnected node." );
+ assert.equal( div.css("height"), "4px", "Height on disconnected node." );
div2 = jQuery( "
").appendTo("body");
- equal( div2.find("input").css("height"), "20px", "Height on hidden input." );
- equal( div2.find("textarea").css("height"), "20px", "Height on hidden textarea." );
- equal( div2.find("div").css("height"), "20px", "Height on hidden div." );
+ assert.equal( div2.find("input").css("height"), "20px", "Height on hidden input." );
+ assert.equal( div2.find("textarea").css("height"), "20px", "Height on hidden textarea." );
+ assert.equal( div2.find("div").css("height"), "20px", "Height on hidden div." );
div2.remove();
@@ -39,42 +39,42 @@ test("css(String|Hash)", function() {
width = parseFloat(jQuery("#nothiddendiv").css("width"));
height = parseFloat(jQuery("#nothiddendiv").css("height"));
jQuery("#nothiddendiv").css({ "overflow":"hidden", "width": -1, "height": -1 });
- equal( parseFloat(jQuery("#nothiddendiv").css("width")), 0, "Test negative width set to 0");
- equal( parseFloat(jQuery("#nothiddendiv").css("height")), 0, "Test negative height set to 0");
+ assert.equal( parseFloat(jQuery("#nothiddendiv").css("width")), 0, "Test negative width set to 0");
+ assert.equal( parseFloat(jQuery("#nothiddendiv").css("height")), 0, "Test negative height set to 0");
- equal( jQuery("
").css("display"), "none", "Styles on disconnected nodes");
+ assert.equal( jQuery("
").css("display"), "none", "Styles on disconnected nodes");
jQuery("#floatTest").css({"float": "right"});
- equal( jQuery("#floatTest").css("float"), "right", "Modified CSS float using \"float\": Assert float is right");
+ assert.equal( jQuery("#floatTest").css("float"), "right", "Modified CSS float using \"float\": Assert float is right");
jQuery("#floatTest").css({"font-size": "30px"});
- equal( jQuery("#floatTest").css("font-size"), "30px", "Modified CSS font-size: Assert font-size is 30px");
+ assert.equal( jQuery("#floatTest").css("font-size"), "30px", "Modified CSS font-size: Assert font-size is 30px");
jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) {
jQuery("#foo").css({"opacity": n});
- equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
+ assert.equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
jQuery("#foo").css({"opacity": parseFloat(n)});
- equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
+ assert.equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
});
jQuery("#foo").css({"opacity": ""});
- equal( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
+ assert.equal( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
- equal( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" );
+ assert.equal( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" );
jQuery("#empty").css({ "opacity": "1" });
- equal( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
+ assert.equal( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
div = jQuery("#nothiddendiv");
child = jQuery("#nothiddendivchild");
- equal( parseInt(div.css("fontSize"), 10), 16, "Verify fontSize px set." );
- equal( parseInt(div.css("font-size"), 10), 16, "Verify fontSize px set." );
- equal( parseInt(child.css("fontSize"), 10), 16, "Verify fontSize px set." );
- equal( parseInt(child.css("font-size"), 10), 16, "Verify fontSize px set." );
+ assert.equal( parseInt(div.css("fontSize"), 10), 16, "Verify fontSize px set." );
+ assert.equal( parseInt(div.css("font-size"), 10), 16, "Verify fontSize px set." );
+ assert.equal( parseInt(child.css("fontSize"), 10), 16, "Verify fontSize px set." );
+ assert.equal( parseInt(child.css("font-size"), 10), 16, "Verify fontSize px set." );
child.css("height", "100%");
- equal( child[0].style.height, "100%", "Make sure the height is being set correctly." );
+ assert.equal( child[0].style.height, "100%", "Make sure the height is being set correctly." );
child.attr("class", "em");
- equal( parseInt(child.css("fontSize"), 10), 32, "Verify fontSize em set." );
+ assert.equal( parseInt(child.css("fontSize"), 10), 32, "Verify fontSize em set." );
// Have to verify this as the result depends upon the browser's CSS
// support for font-size percentages
@@ -85,128 +85,128 @@ test("css(String|Hash)", function() {
checkval = prctval;
}
- equal( prctval, checkval, "Verify fontSize % set." );
+ assert.equal( prctval, checkval, "Verify fontSize % set." );
- equal( typeof child.css("width"), "string", "Make sure that a string width is returned from css('width')." );
+ assert.equal( typeof child.css("width"), "string", "Make sure that a string width is returned from css('width')." );
old = child[0].style.height;
// Test NaN
child.css("height", parseFloat("zoo"));
- equal( child[0].style.height, old, "Make sure height isn't changed on NaN." );
+ assert.equal( child[0].style.height, old, "Make sure height isn't changed on NaN." );
// Test null
child.css("height", null);
- equal( child[0].style.height, old, "Make sure height isn't changed on null." );
+ assert.equal( child[0].style.height, old, "Make sure height isn't changed on null." );
old = child[0].style.fontSize;
// Test NaN
child.css("font-size", parseFloat("zoo"));
- equal( child[0].style.fontSize, old, "Make sure font-size isn't changed on NaN." );
+ assert.equal( child[0].style.fontSize, old, "Make sure font-size isn't changed on NaN." );
// Test null
child.css("font-size", null);
- equal( child[0].style.fontSize, old, "Make sure font-size isn't changed on null." );
+ assert.equal( child[0].style.fontSize, old, "Make sure font-size isn't changed on null." );
- strictEqual( child.css( "x-fake" ), undefined, "Make sure undefined is returned from css(nonexistent)." );
+ assert.strictEqual( child.css( "x-fake" ), undefined, "Make sure undefined is returned from css(nonexistent)." );
div = jQuery( "
" ).css({ position: "absolute", "z-index": 1000 }).appendTo( "#qunit-fixture" );
- strictEqual( div.css( "z-index" ), "1000",
+ assert.strictEqual( div.css( "z-index" ), "1000",
"Make sure that a string z-index is returned from css('z-index') (#14432)." );
});
-test( "css() explicit and relative values", function() {
- expect( 29 );
+QUnit.test( "css() explicit and relative values", function( assert ) {
+ assert.expect( 29 );
var $elem = jQuery("#nothiddendiv");
$elem.css({ "width": 1, "height": 1, "paddingLeft": "1px", "opacity": 1 });
- equal( $elem.css("width"), "1px", "Initial css set or width/height works (hash)" );
- equal( $elem.css("paddingLeft"), "1px", "Initial css set of paddingLeft works (hash)" );
- equal( $elem.css("opacity"), "1", "Initial css set of opacity works (hash)" );
+ assert.equal( $elem.css("width"), "1px", "Initial css set or width/height works (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "1px", "Initial css set of paddingLeft works (hash)" );
+ assert.equal( $elem.css("opacity"), "1", "Initial css set of opacity works (hash)" );
$elem.css({ width: "+=9" });
- equal( $elem.css("width"), "10px", "'+=9' on width (hash)" );
+ assert.equal( $elem.css("width"), "10px", "'+=9' on width (hash)" );
$elem.css({ "width": "-=9" });
- equal( $elem.css("width"), "1px", "'-=9' on width (hash)" );
+ assert.equal( $elem.css("width"), "1px", "'-=9' on width (hash)" );
$elem.css({ "width": "+=9px" });
- equal( $elem.css("width"), "10px", "'+=9px' on width (hash)" );
+ assert.equal( $elem.css("width"), "10px", "'+=9px' on width (hash)" );
$elem.css({ "width": "-=9px" });
- equal( $elem.css("width"), "1px", "'-=9px' on width (hash)" );
+ assert.equal( $elem.css("width"), "1px", "'-=9px' on width (hash)" );
$elem.css( "width", "+=9" );
- equal( $elem.css("width"), "10px", "'+=9' on width (params)" );
+ assert.equal( $elem.css("width"), "10px", "'+=9' on width (params)" );
$elem.css( "width", "-=9" ) ;
- equal( $elem.css("width"), "1px", "'-=9' on width (params)" );
+ assert.equal( $elem.css("width"), "1px", "'-=9' on width (params)" );
$elem.css( "width", "+=9px" );
- equal( $elem.css("width"), "10px", "'+=9px' on width (params)" );
+ assert.equal( $elem.css("width"), "10px", "'+=9px' on width (params)" );
$elem.css( "width", "-=9px" );
- equal( $elem.css("width"), "1px", "'-=9px' on width (params)" );
+ assert.equal( $elem.css("width"), "1px", "'-=9px' on width (params)" );
$elem.css( "width", "-=-9px" );
- equal( $elem.css("width"), "10px", "'-=-9px' on width (params)" );
+ assert.equal( $elem.css("width"), "10px", "'-=-9px' on width (params)" );
$elem.css( "width", "+=-9px" );
- equal( $elem.css("width"), "1px", "'+=-9px' on width (params)" );
+ assert.equal( $elem.css("width"), "1px", "'+=-9px' on width (params)" );
$elem.css({ "paddingLeft": "+=4" });
- equal( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (hash)" );
$elem.css({ "paddingLeft": "-=4" });
- equal( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (hash)" );
$elem.css({ "paddingLeft": "+=4px" });
- equal( $elem.css("paddingLeft"), "5px", "'+=4px' on paddingLeft (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "5px", "'+=4px' on paddingLeft (hash)" );
$elem.css({ "paddingLeft": "-=4px" });
- equal( $elem.css("paddingLeft"), "1px", "'-=4px' on paddingLeft (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "1px", "'-=4px' on paddingLeft (hash)" );
$elem.css({ "padding-left": "+=4" });
- equal( $elem.css("paddingLeft"), "5px", "'+=4' on padding-left (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "5px", "'+=4' on padding-left (hash)" );
$elem.css({ "padding-left": "-=4" });
- equal( $elem.css("paddingLeft"), "1px", "'-=4' on padding-left (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "1px", "'-=4' on padding-left (hash)" );
$elem.css({ "padding-left": "+=4px" });
- equal( $elem.css("paddingLeft"), "5px", "'+=4px' on padding-left (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "5px", "'+=4px' on padding-left (hash)" );
$elem.css({ "padding-left": "-=4px" });
- equal( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (hash)" );
+ assert.equal( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (hash)" );
$elem.css( "paddingLeft", "+=4" );
- equal( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (params)" );
+ assert.equal( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (params)" );
$elem.css( "paddingLeft", "-=4" );
- equal( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (params)" );
+ assert.equal( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (params)" );
$elem.css( "padding-left", "+=4px" );
- equal( $elem.css("paddingLeft"), "5px", "'+=4px' on padding-left (params)" );
+ assert.equal( $elem.css("paddingLeft"), "5px", "'+=4px' on padding-left (params)" );
$elem.css( "padding-left", "-=4px" );
- equal( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (params)" );
+ assert.equal( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (params)" );
$elem.css({ "opacity": "-=0.5" });
- equal( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (hash)" );
+ assert.equal( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (hash)" );
$elem.css({ "opacity": "+=0.5" });
- equal( $elem.css("opacity"), "1", "'+=0.5' on opacity (hash)" );
+ assert.equal( $elem.css("opacity"), "1", "'+=0.5' on opacity (hash)" );
$elem.css( "opacity", "-=0.5" );
- equal( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (params)" );
+ assert.equal( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (params)" );
$elem.css( "opacity", "+=0.5" );
- equal( $elem.css("opacity"), "1", "'+=0.5' on opacity (params)" );
+ assert.equal( $elem.css("opacity"), "1", "'+=0.5' on opacity (params)" );
});
-test( "css() non-px relative values (gh-1711)", function() {
- expect( 17 );
+QUnit.test( "css() non-px relative values (gh-1711)", function( assert ) {
+ assert.expect( 17 );
var cssCurrent,
units = {},
@@ -225,11 +225,11 @@ test( "css() non-px relative values (gh-1711)", function() {
// Require a difference of no more than one pixel
difference = Math.abs( cssCurrent - expected );
if ( difference <= 1 ) {
- ok( true, message );
+ assert.ok( true, message );
// ...or fail with actual and expected values
} else {
- ok( false, message + " (actual " + cssCurrent + ", expected " + expected + ")" );
+ assert.ok( false, message + " (actual " + cssCurrent + ", expected " + expected + ")" );
}
},
getUnits = function( prop ) {
@@ -271,36 +271,36 @@ test( "css() non-px relative values (gh-1711)", function() {
add( "lineHeight", 50, "%" );
});
-test("css(String, Object)", function() {
- expect( 19 );
+QUnit.test("css(String, Object)", function( assert ) {
+ assert.expect( 19 );
var j, div, display, ret, success;
jQuery("#floatTest").css("float", "left");
- equal( jQuery("#floatTest").css("float"), "left", "Modified CSS float using \"float\": Assert float is left");
+ assert.equal( jQuery("#floatTest").css("float"), "left", "Modified CSS float using \"float\": Assert float is left");
jQuery("#floatTest").css("font-size", "20px");
- equal( jQuery("#floatTest").css("font-size"), "20px", "Modified CSS font-size: Assert font-size is 20px");
+ assert.equal( jQuery("#floatTest").css("font-size"), "20px", "Modified CSS font-size: Assert font-size is 20px");
jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) {
jQuery("#foo").css("opacity", n);
- equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
+ assert.equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
jQuery("#foo").css("opacity", parseFloat(n));
- equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
+ assert.equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
});
jQuery("#foo").css("opacity", "");
- equal( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
+ assert.equal( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
// using contents will get comments regular, text, and comment nodes
j = jQuery("#nonnodes").contents();
j.css("overflow", "visible");
- equal( j.css("overflow"), "visible", "Check node,textnode,comment css works" );
- equal( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
+ assert.equal( j.css("overflow"), "visible", "Check node,textnode,comment css works" );
+ assert.equal( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );
div = jQuery("#nothiddendiv");
display = div.css("display");
ret = div.css("display", undefined);
- equal( ret, div, "Make sure setting undefined returns the original set." );
- equal( div.css("display"), display, "Make sure that the display wasn't changed." );
+ assert.equal( ret, div, "Make sure setting undefined returns the original set." );
+ assert.equal( div.css("display"), display, "Make sure that the display wasn't changed." );
success = true;
try {
@@ -309,30 +309,30 @@ test("css(String, Object)", function() {
catch (e) {
success = false;
}
- ok( success, "Setting RGBA values does not throw Error (#5509)" );
+ assert.ok( success, "Setting RGBA values does not throw Error (#5509)" );
jQuery( "#foo" ).css( "font", "7px/21px sans-serif" );
- strictEqual( jQuery( "#foo" ).css( "line-height" ), "21px",
+ assert.strictEqual( jQuery( "#foo" ).css( "line-height" ), "21px",
"Set font shorthand property (#14759)" );
});
-test( "css(String, Object) with negative values", function() {
- expect( 4 );
+QUnit.test( "css(String, Object) with negative values", function( assert ) {
+ assert.expect( 4 );
jQuery( "#nothiddendiv" ).css( "margin-top", "-10px" );
jQuery( "#nothiddendiv" ).css( "margin-left", "-10px" );
- equal( jQuery( "#nothiddendiv" ).css( "margin-top" ), "-10px", "Ensure negative top margins work." );
- equal( jQuery( "#nothiddendiv" ).css( "margin-left" ), "-10px", "Ensure negative left margins work." );
+ assert.equal( jQuery( "#nothiddendiv" ).css( "margin-top" ), "-10px", "Ensure negative top margins work." );
+ assert.equal( jQuery( "#nothiddendiv" ).css( "margin-left" ), "-10px", "Ensure negative left margins work." );
jQuery( "#nothiddendiv" ).css( "position", "absolute" );
jQuery( "#nothiddendiv" ).css( "top", "-20px" );
jQuery( "#nothiddendiv" ).css( "left", "-20px" );
- equal( jQuery( "#nothiddendiv" ).css( "top" ), "-20px", "Ensure negative top values work." );
- equal( jQuery( "#nothiddendiv" ).css( "left" ), "-20px", "Ensure negative left values work." );
+ assert.equal( jQuery( "#nothiddendiv" ).css( "top" ), "-20px", "Ensure negative top values work." );
+ assert.equal( jQuery( "#nothiddendiv" ).css( "left" ), "-20px", "Ensure negative left values work." );
});
-test( "css(Array)", function() {
- expect( 2 );
+QUnit.test( "css(Array)", function( assert ) {
+ assert.expect( 2 );
var expectedMany = {
"overflow": "visible",
@@ -343,12 +343,12 @@ test( "css(Array)", function() {
},
elem = jQuery("
").appendTo("#qunit-fixture");
- deepEqual( elem.css( expectedMany ).css([ "overflow", "width" ]), expectedMany, "Getting multiple element array" );
- deepEqual( elem.css( expectedSingle ).css([ "width" ]), expectedSingle, "Getting single element array" );
+ assert.deepEqual( elem.css( expectedMany ).css([ "overflow", "width" ]), expectedMany, "Getting multiple element array" );
+ assert.deepEqual( elem.css( expectedSingle ).css([ "width" ]), expectedSingle, "Getting single element array" );
});
-test("css(String, Function)", function() {
- expect(3);
+QUnit.test("css(String, Function)", function( assert ) {
+ assert.expect(3);
var index,
sizes = ["10px", "20px", "30px"];
@@ -371,15 +371,15 @@ test("css(String, Function)", function() {
jQuery("#cssFunctionTest div").each(function() {
var computedSize = jQuery(this).css("font-size"),
expectedSize = sizes[index];
- equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
+ assert.equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
index++;
});
jQuery("#cssFunctionTest").remove();
});
-test("css(String, Function) with incoming value", function() {
- expect(3);
+QUnit.test("css(String, Function) with incoming value", function( assert ) {
+ assert.expect(3);
var index,
sizes = ["10px", "20px", "30px"];
@@ -401,7 +401,7 @@ test("css(String, Function) with incoming value", function() {
jQuery("#cssFunctionTest div").css("font-size", function(i, computedSize) {
var expectedSize = sizes[index];
- equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
+ assert.equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
index++;
return computedSize;
});
@@ -409,8 +409,8 @@ test("css(String, Function) with incoming value", function() {
jQuery("#cssFunctionTest").remove();
});
-test("css(Object) where values are Functions", function() {
- expect(3);
+QUnit.test("css(Object) where values are Functions", function( assert ) {
+ assert.expect(3);
var index,
sizes = ["10px", "20px", "30px"];
@@ -433,15 +433,15 @@ test("css(Object) where values are Functions", function() {
jQuery("#cssFunctionTest div").each(function() {
var computedSize = jQuery(this).css("font-size"),
expectedSize = sizes[index];
- equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
+ assert.equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
index++;
});
jQuery("#cssFunctionTest").remove();
});
-test("css(Object) where values are Functions with incoming values", function() {
- expect(3);
+QUnit.test("css(Object) where values are Functions with incoming values", function( assert ) {
+ assert.expect(3);
var index,
sizes = ["10px", "20px", "30px"];
@@ -463,7 +463,7 @@ test("css(Object) where values are Functions with incoming values", function() {
jQuery("#cssFunctionTest div").css({"font-size": function(i, computedSize) {
var expectedSize = sizes[index];
- equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
+ assert.equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
index++;
return computedSize;
}});
@@ -471,39 +471,39 @@ test("css(Object) where values are Functions with incoming values", function() {
jQuery("#cssFunctionTest").remove();
});
-test("show(); hide()", function() {
+QUnit.test("show(); hide()", function( assert ) {
- expect( 4 );
+ assert.expect( 4 );
var hiddendiv, div;
hiddendiv = jQuery("div.hidden");
hiddendiv.hide();
- equal( hiddendiv.css("display"), "none", "Cascade-hidden div after hide()" );
+ assert.equal( hiddendiv.css("display"), "none", "Cascade-hidden div after hide()" );
hiddendiv.show();
- equal( hiddendiv.css("display"), "none", "Show does not trump CSS cascade" );
+ assert.equal( hiddendiv.css("display"), "none", "Show does not trump CSS cascade" );
div = jQuery("
").hide();
- equal( div.css("display"), "none", "Detached div hidden" );
+ assert.equal( div.css("display"), "none", "Detached div hidden" );
div.appendTo("#qunit-fixture").show();
- equal( div.css("display"), "block", "Initially-detached div after show()" );
+ assert.equal( div.css("display"), "block", "Initially-detached div after show()" );
});
-test("show();", function() {
+QUnit.test("show();", function( assert ) {
- expect( 18 );
+ assert.expect( 18 );
var hiddendiv, div, pass, old, test;
hiddendiv = jQuery("div.hidden");
- equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
+ assert.equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
hiddendiv.css("display", "block");
- equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
+ assert.equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
hiddendiv.show();
- equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
+ assert.equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
hiddendiv.css("display","");
@@ -514,7 +514,7 @@ test("show();", function() {
pass = false;
}
});
- ok( pass, "Show" );
+ assert.ok( pass, "Show" );
jQuery(
"
" +
@@ -546,7 +546,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
@@ -554,73 +554,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("
").children("div");
div.show().appendTo("#qunit-fixture");
- equal( div.css("display"), "block",
+ assert.equal( div.css("display"), "block",
"A shown-while-detached inline-hidden div inside a visible div has default display " +
"after attachment" );
span = jQuery("
");
span.show();
- equal( span[ 0 ].style.display, "",
+ assert.equal( span[ 0 ].style.display, "",
"show() updates inline style of a detached inline-hidden span" );
span.appendTo("#qunit-fixture");
- equal( span.css("display"), "inline",
+ assert.equal( span.css("display"), "inline",
"A shown-while-detached inline-hidden span has default display after attachment" );
div = jQuery("
");
div.show().appendTo("#qunit-fixture");
- equal( div.css("display"), "inline",
+ assert.equal( div.css("display"), "inline",
"show() does not update inline style of a detached inline-visible div" );
div.remove();
@@ -628,74 +628,74 @@ test( "show() resolves correct default display for detached nodes", function(){
jQuery("#table").append( tr );
tr.detach().hide().show();
- ok( !tr[ 0 ].style.display, "Not-hidden detached tr elements have no inline style" );
+ assert.ok( !tr[ 0 ].style.display, "Not-hidden detached tr elements have no inline style" );
tr.remove();
span = jQuery("
").hide().show();
- ok( !span[ 0 ].style.display, "Not-hidden detached span elements have no inline style" );
+ assert.ok( !span[ 0 ].style.display, "Not-hidden detached span elements have no inline style" );
span.remove();
});
-test("toggle()", function() {
- expect(9);
+QUnit.test("toggle()", function( assert ) {
+ assert.expect(9);
var div, oldHide,
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" );
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, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ assert.ok( !jQuery._data(div, "olddisplay"), "olddisplay 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 {
@@ -704,11 +704,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({
@@ -716,22 +716,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",
@@ -739,42 +739,42 @@ 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");
- 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" );
$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",
@@ -789,64 +789,65 @@ 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" );
}
});
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");
$div.css( "fill-opacity", 1 );
// 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" );
}
);
@@ -859,63 +860,63 @@ testIframeWithCallback( "css('width') should work correctly before document read
supportsFractionalGBCR = 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" ],
@@ -930,32 +931,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");
@@ -965,39 +966,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 (filter:alpha with spaces)" );
+ assert.equal( Math.round( el.css("opacity") * 100 ), 10, "opacity from style sheet (filter:alpha with spaces)" );
el.removeClass("opacityWithSpaces_t12685").addClass("opacityNoSpaces_t12685");
- equal( Math.round( el.css("opacity") * 100 ), 20, "opacity from style sheet (filter:alpha without spaces)" );
+ assert.equal( Math.round( el.css("opacity") * 100 ), 20, "opacity from style sheet (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
@@ -1006,38 +1007,38 @@ 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( "
Header " ).appendTo( "#qunit-fixture" );
- ok( $a.is( ":visible" ), "Anchor tag with flow content is visible (gh-2227)" );
+ assert.ok( $a.is( ":visible" ), "Anchor tag with flow content is visible (gh-2227)" );
});
-test( "Keep the last style if the new one isn't recognized by the browser (#14836)", function() {
- expect( 2 );
+QUnit.test( "Keep the last style if the new one isn't recognized by the browser (#14836)", function( assert ) {
+ assert.expect( 2 );
var el;
el = jQuery( "
" ).css( "position", "absolute" ).css( "position", "fake value" );
- equal( el.css( "position" ), "absolute", "The old style is kept when setting an unrecognized value" );
+ assert.equal( el.css( "position" ), "absolute", "The old style is kept when setting an unrecognized value" );
el = jQuery( "
" ).css( "position", "absolute" ).css( "position", " " );
- equal( el.css( "position" ), "absolute", "The old style is kept when setting to a space" );
+ assert.equal( el.css( "position" ), "absolute", "The old style is kept when setting to a space" );
});
-test( "Reset the style if set to an empty string", function() {
- expect( 1 );
+QUnit.test( "Reset the style if set to an empty string", function( assert ) {
+ assert.expect( 1 );
var el = jQuery( "
" ).css( "position", "absolute" ).css( "position", "" );
// Some browsers return an empty string; others "static". Both those cases mean the style
// was reset successfully so accept them both.
- equal( el.css( "position" ) || "static", "static",
+ assert.equal( el.css( "position" ) || "static", "static",
"The style can be reset by setting to an empty string" );
});
-asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() {
+QUnit.asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function( assert ) {
var baseUrl = document.location.href.replace( /([^\/]*)$/, "" ),
styles = [{
name: "backgroundAttachment",
@@ -1084,8 +1085,8 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
style.expected = style.expected.concat( [ "", "auto" ] );
if ( source.style[ style.name ] === undefined ) {
- ok( true, style.name + ": style isn't supported and therefore not an issue" );
- ok( true );
+ assert.ok( true, style.name + ": style isn't supported and therefore not an issue" );
+ assert.ok( true );
return true;
}
@@ -1100,14 +1101,14 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
$clonedChildren.css( style.name, "" );
window.setTimeout(function() {
- notEqual( $clone.css( style.name ), style.value[ 0 ], "Cloned css was changed" );
+ assert.notEqual( $clone.css( style.name ), style.value[ 0 ], "Cloned css was changed" );
- ok( jQuery.inArray( $source.css( style.name ) !== -1, style.value ),
+ assert.ok( jQuery.inArray( $source.css( style.name ) !== -1, style.value ),
"Clearing clone.css() doesn't affect source.css(): " + style.name +
"; result: " + $source.css( style.name ) +
"; expected: " + style.value.join( "," ) );
- ok( jQuery.inArray( $children.css( style.name ) !== -1, style.value ),
+ assert.ok( jQuery.inArray( $children.css( style.name ) !== -1, style.value ),
"Clearing clonedChildren.css() doesn't affect children.css(): " + style.name +
"; result: " + $children.css( style.name ) +
"; expected: " + style.value.join( "," ) );
@@ -1117,8 +1118,8 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
window.setTimeout( start, 1000 );
});
-test( "show() after hide() should always set display to initial value (#14750)", function() {
- expect( 1 );
+QUnit.test( "show() after hide() should always set display to initial value (#14750)", function( assert ) {
+ assert.expect( 1 );
var div = jQuery( "
" ),
fixture = jQuery( "#qunit-fixture" );
@@ -1126,7 +1127,7 @@ test( "show() after hide() should always set display to initial value (#14750)",
fixture.append( div );
div.css( "display", "inline" ).hide().show().css( "display", "list-item" ).hide().show();
- equal( div.css( "display" ), "list-item", "should get last set display value" );
+ assert.equal( div.css( "display" ), "list-item", "should get last set display value" );
});
// Support: IE < 11
@@ -1138,19 +1139,19 @@ test( "show() after hide() should always set display to initial value (#14750)",
exist = "order" in style || "WebkitOrder" in style;
if ( exist ) {
- test( "Don't append px to CSS \"order\" value (#14049)", function() {
- expect( 1 );
+ QUnit.test( "Don't append px to CSS \"order\" value (#14049)", function( assert ) {
+ assert.expect( 1 );
var $elem = jQuery( "
" );
$elem.css( "order", 2 );
- equal( $elem.css( "order" ), "2", "2 on order" );
+ assert.equal( $elem.css( "order" ), "2", "2 on order" );
});
}
})();
-test( "Do not throw on frame elements from css method (#15098)", function() {
- expect( 1 );
+QUnit.test( "Do not throw on frame elements from css method (#15098)", function( assert ) {
+ assert.expect( 1 );
var frameWin, frameDoc,
frameElement = document.createElement( "iframe" ),
@@ -1168,9 +1169,9 @@ test( "Do not throw on frame elements from css method (#15098)", function() {
try {
jQuery( frameDoc.body ).css( "direction" );
- ok( true, "It didn't throw" );
+ assert.ok( true, "It didn't throw" );
} catch ( _ ) {
- ok( false, "It did throw" );
+ assert.ok( false, "It did throw" );
}
});
@@ -1184,7 +1185,7 @@ test( "Do not throw on frame elements from css method (#15098)", function() {
} );
}
- test( "Don't default to a cached previously used wrong prefixed name (gh-2015)", function() {
+ QUnit.test( "Don't default to a cached previously used wrong prefixed name (gh-2015)", function( assert ) {
// Note: this test needs a property we know is only supported in a prefixed version
// by at least one of our main supported browsers. This may get out of date so let's
// use -(webkit|moz)-appearance as well as those two are not on a standards track.
@@ -1214,7 +1215,7 @@ test( "Do not throw on frame elements from css method (#15098)", function() {
} );
}
- expect( !!appearanceName + !!transformName + 1 );
+ assert.expect( !!appearanceName + !!transformName + 1 );
resetCssPropsFor( "appearance" );
resetCssPropsFor( "transform" );
@@ -1232,23 +1233,23 @@ test( "Do not throw on frame elements from css method (#15098)", function() {
elemStyle = elem[ 0 ].style;
if ( appearanceName ) {
- equal( elemStyle[ appearanceName ], "none", "setting properly-prefixed appearance" );
+ assert.equal( elemStyle[ appearanceName ], "none", "setting properly-prefixed appearance" );
}
if ( transformName ) {
- equal( elemStyle[ transformName ], transformVal, "setting properly-prefixed transform" );
+ assert.equal( elemStyle[ transformName ], transformVal, "setting properly-prefixed transform" );
}
- equal( elemStyle[ "undefined" ], undefined, "Nothing writes to node.style.undefined" );
+ assert.equal( elemStyle[ "undefined" ], undefined, "Nothing writes to node.style.undefined" );
} );
- test( "Don't detect fake set properties on a node when caching the prefixed version", function() {
- expect( 1 );
+ QUnit.test( "Don't detect fake set properties on a node when caching the prefixed version", function( assert ) {
+ assert.expect( 1 );
var elem = jQuery( "
" ),
style = elem[ 0 ].style;
style.MozFakeProperty = "old value";
elem.css( "fakeProperty", "new value" );
- equal( style.MozFakeProperty, "old value", "Fake prefixed property is not cached" );
+ assert.equal( style.MozFakeProperty, "old value", "Fake prefixed property is not cached" );
} );
} )();
diff --git a/test/unit/data.js b/test/unit/data.js
index f86704dda..21f760473 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -1,137 +1,137 @@
-module("data", { teardown: moduleTeardown });
+QUnit.module("data", { teardown: moduleTeardown });
-test("expando", function(){
- expect(1);
+QUnit.test("expando", function( assert ){
+ assert.expect(1);
- equal(jQuery.expando !== undefined, true, "jQuery is exposing the expando");
+ assert.equal(jQuery.expando !== undefined, true, "jQuery is exposing the expando");
});
-test( "jQuery.data & removeData, expected returns", function() {
- expect(4);
+QUnit.test( "jQuery.data & removeData, expected returns", function( assert ) {
+ assert.expect(4);
var elem = document.body;
- equal(
+ assert.equal(
jQuery.data( elem, "hello", "world" ), "world",
"jQuery.data( elem, key, value ) returns value"
);
- equal(
+ assert.equal(
jQuery.data( elem, "hello" ), "world",
"jQuery.data( elem, key ) returns value"
);
- deepEqual(
+ assert.deepEqual(
jQuery.data( elem, { goodnight: "moon" }), { goodnight: "moon" },
"jQuery.data( elem, obj ) returns obj"
);
- equal(
+ assert.equal(
jQuery.removeData( elem, "hello" ), undefined,
"jQuery.removeData( elem, key, value ) returns undefined"
);
});
-test( "jQuery._data & _removeData, expected returns", function() {
- expect(4);
+QUnit.test( "jQuery._data & _removeData, expected returns", function( assert ) {
+ assert.expect(4);
var elem = document.body;
- equal(
+ assert.equal(
jQuery._data( elem, "hello", "world" ), "world",
"jQuery._data( elem, key, value ) returns value"
);
- equal(
+ assert.equal(
jQuery._data( elem, "hello" ), "world",
"jQuery._data( elem, key ) returns value"
);
- deepEqual(
+ assert.deepEqual(
jQuery._data( elem, { goodnight: "moon" }), { goodnight: "moon" },
"jQuery._data( elem, obj ) returns obj"
);
- equal(
+ assert.equal(
jQuery._removeData( elem, "hello" ), undefined,
"jQuery._removeData( elem, key, value ) returns undefined"
);
});
-test( "jQuery.hasData no side effects", function() {
- expect(1);
+QUnit.test( "jQuery.hasData no side effects", function( assert ) {
+ assert.expect(1);
var obj = {};
jQuery.hasData( obj );
- equal( Object.getOwnPropertyNames( obj ).length, 0,
+ assert.equal( Object.getOwnPropertyNames( obj ).length, 0,
"No data expandos where added when calling jQuery.hasData(o)"
);
});
-function dataTests( elem ) {
+function dataTests( elem, assert ) {
var dataObj, internalDataObj;
- equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" );
- strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" );
+ assert.equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" );
+ assert.strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" );
dataObj = jQuery.data(elem);
- equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" );
- strictEqual( jQuery.data(elem), dataObj, "Calling jQuery.data returns the same data object when called multiple times" );
+ assert.equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" );
+ assert.strictEqual( jQuery.data(elem), dataObj, "Calling jQuery.data returns the same data object when called multiple times" );
- strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );
+ assert.strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );
dataObj["foo"] = "bar";
- equal( jQuery.data(elem, "foo"), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );
+ assert.equal( jQuery.data(elem, "foo"), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );
- strictEqual( jQuery.hasData(elem), true, "jQuery.hasData agrees data exists when data exists" );
+ assert.strictEqual( jQuery.hasData(elem), true, "jQuery.hasData agrees data exists when data exists" );
jQuery.data(elem, "foo", "baz");
- equal( jQuery.data(elem, "foo"), "baz", "Data can be changed by jQuery.data" );
- equal( dataObj["foo"], "baz", "Changes made through jQuery.data propagate to referenced data object" );
+ assert.equal( jQuery.data(elem, "foo"), "baz", "Data can be changed by jQuery.data" );
+ assert.equal( dataObj["foo"], "baz", "Changes made through jQuery.data propagate to referenced data object" );
jQuery.data(elem, "foo", undefined);
- equal( jQuery.data(elem, "foo"), "baz", "Data is not unset by passing undefined to jQuery.data" );
+ assert.equal( jQuery.data(elem, "foo"), "baz", "Data is not unset by passing undefined to jQuery.data" );
jQuery.data(elem, "foo", null);
- strictEqual( jQuery.data(elem, "foo"), null, "Setting null using jQuery.data works OK" );
+ assert.strictEqual( jQuery.data(elem, "foo"), null, "Setting null using jQuery.data works OK" );
jQuery.data(elem, "foo", "foo1");
jQuery.data(elem, { "bar" : "baz", "boom" : "bloz" });
- strictEqual( jQuery.data(elem, "foo"), "foo1", "Passing an object extends the data object instead of replacing it" );
- equal( jQuery.data(elem, "boom"), "bloz", "Extending the data object works" );
+ assert.strictEqual( jQuery.data(elem, "foo"), "foo1", "Passing an object extends the data object instead of replacing it" );
+ assert.equal( jQuery.data(elem, "boom"), "bloz", "Extending the data object works" );
jQuery._data(elem, "foo", "foo2", true);
- equal( jQuery._data(elem, "foo"), "foo2", "Setting internal data works" );
- equal( jQuery.data(elem, "foo"), "foo1", "Setting internal data does not override user data" );
+ assert.equal( jQuery._data(elem, "foo"), "foo2", "Setting internal data works" );
+ assert.equal( jQuery.data(elem, "foo"), "foo1", "Setting internal data does not override user data" );
internalDataObj = jQuery._data( elem );
- ok( internalDataObj, "Internal data object exists" );
- notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" );
+ assert.ok( internalDataObj, "Internal data object exists" );
+ assert.notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" );
- strictEqual( elem.boom, undefined, "Data is never stored directly on the object" );
+ assert.strictEqual( elem.boom, undefined, "Data is never stored directly on the object" );
jQuery.removeData(elem, "foo");
- strictEqual( jQuery.data(elem, "foo"), undefined, "jQuery.removeData removes single properties" );
+ assert.strictEqual( jQuery.data(elem, "foo"), undefined, "jQuery.removeData removes single properties" );
jQuery.removeData(elem);
- strictEqual( jQuery._data(elem), internalDataObj, "jQuery.removeData does not remove internal data if it exists" );
+ assert.strictEqual( jQuery._data(elem), internalDataObj, "jQuery.removeData does not remove internal data if it exists" );
jQuery.data(elem, "foo", "foo1");
jQuery._data(elem, "foo", "foo2");
- equal( jQuery.data(elem, "foo"), "foo1", "(sanity check) Ensure data is set in user data object" );
- equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );
+ assert.equal( jQuery.data(elem, "foo"), "foo1", "(sanity check) Ensure data is set in user data object" );
+ assert.equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );
- strictEqual( jQuery._data(elem, jQuery.expando), undefined, "Removing the last item in internal data destroys the internal data object" );
+ assert.strictEqual( jQuery._data(elem, jQuery.expando), undefined, "Removing the last item in internal data destroys the internal data object" );
jQuery._data(elem, "foo", "foo2");
- equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );
+ assert.equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );
jQuery.removeData(elem, "foo");
- equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" );
+ assert.equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" );
}
-test("jQuery.data(div)", function() {
- expect( 25 );
+QUnit.test("jQuery.data(div)", function( assert ) {
+ assert.expect( 25 );
var div = document.createElement("div");
- dataTests( div );
+ dataTests( div, assert );
// We stored one key in the private data
// assert that nothing else was put in there, and that that
@@ -139,79 +139,79 @@ test("jQuery.data(div)", function() {
QUnit.expectJqData( this, div, "foo" );
});
-test("jQuery.data({})", function() {
- expect( 25 );
+QUnit.test("jQuery.data({})", function( assert ) {
+ assert.expect( 25 );
- dataTests( {} );
+ dataTests( {}, assert );
});
-test("jQuery.data(window)", function() {
- expect( 25 );
+QUnit.test("jQuery.data(window)", function( assert ) {
+ assert.expect( 25 );
// remove bound handlers from window object to stop potential false positives caused by fix for #5280 in
// transports/xhr.js
jQuery( window ).off( "unload" );
- dataTests( window );
+ dataTests( window, assert );
});
-test("jQuery.data(document)", function() {
- expect( 25 );
+QUnit.test("jQuery.data(document)", function( assert ) {
+ assert.expect( 25 );
- dataTests( document );
+ dataTests( document, assert );
QUnit.expectJqData( this, document, "foo" );
});
-test("jQuery.data(
)", function() {
- expect( 25 );
+QUnit.test("jQuery.data()", function( assert ) {
+ assert.expect( 25 );
- dataTests( document.createElement("embed") );
+ dataTests( document.createElement("embed"), assert );
});
-test("jQuery.data(object/flash)", function() {
- expect( 25 );
+QUnit.test("jQuery.data(object/flash)", function( assert ) {
+ assert.expect( 25 );
var flash = document.createElement("object");
flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" );
- dataTests( flash );
+ dataTests( flash, assert );
});
// attempting to access the data of an undefined jQuery element should be undefined
-test("jQuery().data() === undefined (#14101)", function() {
- expect( 2 );
+QUnit.test("jQuery().data() === undefined (#14101)", function( assert ) {
+ assert.expect( 2 );
- strictEqual(jQuery().data(), undefined);
- strictEqual(jQuery().data("key"), undefined);
+ assert.strictEqual(jQuery().data(), undefined);
+ assert.strictEqual(jQuery().data("key"), undefined);
});
-test(".data()", function() {
- expect(5);
+QUnit.test(".data()", function( assert ) {
+ assert.expect(5);
var div, dataObj, nodiv, obj;
div = jQuery("#foo");
- strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );
+ assert.strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );
div.data("test", "success");
dataObj = div.data();
- deepEqual( dataObj, {test: "success"}, "data() returns entire data object with expected properties" );
- strictEqual( div.data("foo"), undefined, "Make sure that missing result is still undefined" );
+ assert.deepEqual( dataObj, {test: "success"}, "data() returns entire data object with expected properties" );
+ assert.strictEqual( div.data("foo"), undefined, "Make sure that missing result is still undefined" );
nodiv = jQuery("#unfound");
- equal( nodiv.data(), null, "data() on empty set returns null" );
+ assert.equal( nodiv.data(), null, "data() on empty set returns null" );
obj = { foo: "bar" };
jQuery(obj).data("foo", "baz");
dataObj = jQuery.extend(true, {}, jQuery(obj).data());
- deepEqual( dataObj, { "foo": "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
+ assert.deepEqual( dataObj, { "foo": "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
});
-function testDataTypes( $obj ) {
+function testDataTypes( $obj, assert ) {
jQuery.each({
"null": null,
"true": true,
@@ -227,53 +227,53 @@ function testDataTypes( $obj ) {
"regex": /test/,
"function": function() {}
}, function( type, value ) {
- strictEqual( $obj.data( "test", value ).data("test"), value, "Data set to " + type );
+ assert.strictEqual( $obj.data( "test", value ).data("test"), value, "Data set to " + type );
});
}
-test("jQuery(Element).data(String, Object).data(String)", function() {
- expect( 18 );
+QUnit.test("jQuery(Element).data(String, Object).data(String)", function( assert ) {
+ assert.expect( 18 );
var parent = jQuery(""),
div = parent.children();
- strictEqual( div.data("test"), undefined, "No data exists initially" );
- strictEqual( div.data("test", "success").data("test"), "success", "Data added" );
- strictEqual( div.data("test", "overwritten").data("test"), "overwritten", "Data overwritten" );
- strictEqual( div.data("test", undefined).data("test"), "overwritten", ".data(key,undefined) does nothing but is chainable (#5571)");
- strictEqual( div.data("notexist"), undefined, "No data exists for unset key" );
- testDataTypes( div );
+ assert.strictEqual( div.data("test"), undefined, "No data exists initially" );
+ assert.strictEqual( div.data("test", "success").data("test"), "success", "Data added" );
+ assert.strictEqual( div.data("test", "overwritten").data("test"), "overwritten", "Data overwritten" );
+ assert.strictEqual( div.data("test", undefined).data("test"), "overwritten", ".data(key,undefined) does nothing but is chainable (#5571)");
+ assert.strictEqual( div.data("notexist"), undefined, "No data exists for unset key" );
+ testDataTypes( div, assert );
parent.remove();
});
-test("jQuery(plain Object).data(String, Object).data(String)", function() {
- expect( 16 );
+QUnit.test("jQuery(plain Object).data(String, Object).data(String)", function( assert ) {
+ assert.expect( 16 );
// #3748
var $obj = jQuery({ exists: true });
- strictEqual( $obj.data("nothing"), undefined, "Non-existent data returns undefined");
- strictEqual( $obj.data("exists"), undefined, "Object properties are not returned as data" );
- testDataTypes( $obj );
+ assert.strictEqual( $obj.data("nothing"), undefined, "Non-existent data returns undefined");
+ assert.strictEqual( $obj.data("exists"), undefined, "Object properties are not returned as data" );
+ testDataTypes( $obj, assert );
// Clean up
$obj.removeData();
- deepEqual( $obj[0], { exists: true }, "removeData does not clear the object" );
+ assert.deepEqual( $obj[0], { exists: true }, "removeData does not clear the object" );
});
-test(".data(object) does not retain references. #13815", function() {
- expect( 2 );
+QUnit.test(".data(object) does not retain references. #13815", function( assert ) {
+ assert.expect( 2 );
var $divs = jQuery("
").appendTo("#qunit-fixture");
$divs.data({ "type": "foo" });
$divs.eq( 0 ).data( "type", "bar" );
- equal( $divs.eq( 0 ).data("type"), "bar", "Correct updated value" );
- equal( $divs.eq( 1 ).data("type"), "foo", "Original value retained" );
+ assert.equal( $divs.eq( 0 ).data("type"), "bar", "Correct updated value" );
+ assert.equal( $divs.eq( 1 ).data("type"), "foo", "Original value retained" );
});
-test("data-* attributes", function() {
- expect( 46 );
+QUnit.test("data-* attributes", function( assert ) {
+ assert.expect( 46 );
var prop, i, l, metadata, elem,
obj, obj2, check, num, num2,
@@ -282,28 +282,28 @@ test("data-* attributes", function() {
child = jQuery("
"),
dummy = jQuery("
");
- equal( div.data("attr"), undefined, "Check for non-existing data-attr attribute" );
+ assert.equal( div.data("attr"), undefined, "Check for non-existing data-attr attribute" );
div.attr("data-attr", "exists");
- equal( div.data("attr"), "exists", "Check for existing data-attr attribute" );
+ assert.equal( div.data("attr"), "exists", "Check for existing data-attr attribute" );
div.attr("data-attr", "exists2");
- equal( div.data("attr"), "exists", "Check that updates to data- don't update .data()" );
+ assert.equal( div.data("attr"), "exists", "Check that updates to data- don't update .data()" );
div.data("attr", "internal").attr("data-attr", "external");
- equal( div.data("attr"), "internal", "Check for .data('attr') precedence (internal > external data-* attribute)" );
+ assert.equal( div.data("attr"), "internal", "Check for .data('attr') precedence (internal > external data-* attribute)" );
div.remove();
child.appendTo("#qunit-fixture");
- equal( child.data("myobj"), "old data", "Value accessed from data-* attribute");
- equal( child.data("foo-42"), "boosh", "camelCasing does not affect numbers (#1751)" );
+ assert.equal( child.data("myobj"), "old data", "Value accessed from data-* attribute");
+ assert.equal( child.data("foo-42"), "boosh", "camelCasing does not affect numbers (#1751)" );
child.data("myobj", "replaced");
- equal( child.data("myobj"), "replaced", "Original data overwritten");
+ assert.equal( child.data("myobj"), "replaced", "Original data overwritten");
child.data("ignored", "cache");
- equal( child.data("ignored"), "cache", "Cached data used before DOM data-* fallback");
+ assert.equal( child.data("ignored"), "cache", "Cached data used before DOM data-* fallback");
obj = child.data();
obj2 = dummy.data();
@@ -314,25 +314,25 @@ test("data-* attributes", function() {
dummy.remove();
for ( i = 0, l = check.length; i < l; i++ ) {
- ok( obj[ check[i] ], "Make sure data- property exists when calling data-." );
- ok( obj2[ check[i] ], "Make sure data- property exists when calling data-." );
+ assert.ok( obj[ check[i] ], "Make sure data- property exists when calling data-." );
+ assert.ok( obj2[ check[i] ], "Make sure data- property exists when calling data-." );
}
for ( prop in obj ) {
num++;
}
- equal( num, check.length, "Make sure that the right number of properties came through." );
+ assert.equal( num, check.length, "Make sure that the right number of properties came through." );
for ( prop in obj2 ) {
num2++;
}
- equal( num2, check.length, "Make sure that the right number of properties came through." );
+ assert.equal( num2, check.length, "Make sure that the right number of properties came through." );
child.attr("data-other", "newvalue");
- equal( child.data("other"), "test", "Make sure value was pulled in properly from a .data()." );
+ assert.equal( child.data("other"), "test", "Make sure value was pulled in properly from a .data()." );
// attribute parsing
i = 0;
@@ -361,33 +361,33 @@ test("data-* attributes", function() {
.attr("data-null", "null")
.attr("data-string", "test");
- strictEqual( child.data("true"), true, "Primitive true read from attribute");
- strictEqual( child.data("false"), false, "Primitive false read from attribute");
- strictEqual( child.data("five"), 5, "Integer read from attribute");
- strictEqual( child.data("point"), 5.5, "Floating-point number read from attribute");
- strictEqual( child.data("pointe"), "5.5E3",
+ assert.strictEqual( child.data("true"), true, "Primitive true read from attribute");
+ assert.strictEqual( child.data("false"), false, "Primitive false read from attribute");
+ assert.strictEqual( child.data("five"), 5, "Integer read from attribute");
+ assert.strictEqual( child.data("point"), 5.5, "Floating-point number read from attribute");
+ assert.strictEqual( child.data("pointe"), "5.5E3",
"Exponential-notation number read from attribute as string");
- strictEqual( child.data("grande"), "5.574E9",
+ assert.strictEqual( child.data("grande"), "5.574E9",
"Big exponential-notation number read from attribute as string");
- strictEqual( child.data("hexadecimal"), "0x42",
+ assert.strictEqual( child.data("hexadecimal"), "0x42",
"Hexadecimal number read from attribute as string");
- strictEqual( child.data("pointbad"), "5..5",
+ assert.strictEqual( child.data("pointbad"), "5..5",
"Extra-point non-number read from attribute as string");
- strictEqual( child.data("pointbad2"), "-.",
+ assert.strictEqual( child.data("pointbad2"), "-.",
"No-digit non-number read from attribute as string");
- strictEqual( child.data("bigassnum"), "123456789123456789123456789",
+ assert.strictEqual( child.data("bigassnum"), "123456789123456789123456789",
"Bad bigass number read from attribute as string");
- strictEqual( child.data("badjson"), "{123}", "Bad JSON object read from attribute as string");
- strictEqual( child.data("badjson2"), "[abc]", "Bad JSON array read from attribute as string");
- strictEqual( child.data("notjson"), " {}",
+ assert.strictEqual( child.data("badjson"), "{123}", "Bad JSON object read from attribute as string");
+ assert.strictEqual( child.data("badjson2"), "[abc]", "Bad JSON array read from attribute as string");
+ assert.strictEqual( child.data("notjson"), " {}",
"JSON object with leading non-JSON read from attribute as string");
- strictEqual( child.data("notjson2"), "[] ",
+ assert.strictEqual( child.data("notjson2"), "[] ",
"JSON array with trailing non-JSON read from attribute as string");
- strictEqual( child.data("empty"), "", "Empty string read from attribute");
- strictEqual( child.data("space"), " ", "Whitespace string read from attribute");
- strictEqual( child.data("null"), null, "Primitive null read from attribute");
- strictEqual( child.data("string"), "test", "Typical string read from attribute");
- equal( i, 2, "Correct number of JSON parse attempts when reading from attributes" );
+ assert.strictEqual( child.data("empty"), "", "Empty string read from attribute");
+ assert.strictEqual( child.data("space"), " ", "Whitespace string read from attribute");
+ assert.strictEqual( child.data("null"), null, "Primitive null read from attribute");
+ assert.strictEqual( child.data("string"), "test", "Typical string read from attribute");
+ assert.equal( i, 2, "Correct number of JSON parse attempts when reading from attributes" );
jQuery.parseJSON = parseJSON;
child.remove();
@@ -396,23 +396,23 @@ test("data-* attributes", function() {
function testData(index, elem) {
switch (index) {
case 0:
- equal(jQuery(elem).data("foo"), "bar", "Check foo property");
- equal(jQuery(elem).data("bar"), "baz", "Check baz property");
+ assert.equal(jQuery(elem).data("foo"), "bar", "Check foo property");
+ assert.equal(jQuery(elem).data("bar"), "baz", "Check baz property");
break;
case 1:
- equal(jQuery(elem).data("test"), "bar", "Check test property");
- equal(jQuery(elem).data("bar"), "baz", "Check bar property");
+ assert.equal(jQuery(elem).data("test"), "bar", "Check test property");
+ assert.equal(jQuery(elem).data("bar"), "baz", "Check bar property");
break;
case 2:
- equal(jQuery(elem).data("zoooo"), "bar", "Check zoooo property");
- deepEqual(jQuery(elem).data("bar"), {"test":"baz"}, "Check bar property");
+ assert.equal(jQuery(elem).data("zoooo"), "bar", "Check zoooo property");
+ assert.deepEqual(jQuery(elem).data("bar"), {"test":"baz"}, "Check bar property");
break;
case 3:
- equal(jQuery(elem).data("number"), true, "Check number property");
- deepEqual(jQuery(elem).data("stuff"), [2,8], "Check stuff property");
+ assert.equal(jQuery(elem).data("number"), true, "Check number property");
+ assert.deepEqual(jQuery(elem).data("stuff"), [2,8], "Check stuff property");
break;
default:
- ok(false, ["Assertion failed on index ", index, ", with data"].join(""));
+ assert.ok(false, ["Assertion failed on index ", index, ", with data"].join(""));
}
}
@@ -423,138 +423,138 @@ test("data-* attributes", function() {
elem.remove();
});
-test(".data(Object)", function() {
- expect(4);
+QUnit.test(".data(Object)", function( assert ) {
+ assert.expect(4);
var obj, jqobj,
div = jQuery("
");
div.data({ "test": "in", "test2": "in2" });
- equal( div.data("test"), "in", "Verify setting an object in data" );
- equal( div.data("test2"), "in2", "Verify setting an object in data" );
+ assert.equal( div.data("test"), "in", "Verify setting an object in data" );
+ assert.equal( div.data("test2"), "in2", "Verify setting an object in data" );
obj = {test:"unset"};
jqobj = jQuery(obj);
jqobj.data("test", "unset");
jqobj.data({ "test": "in", "test2": "in2" });
- equal( jQuery.data(obj)["test"], "in", "Verify setting an object on an object extends the data object" );
- equal( obj["test2"], undefined, "Verify setting an object on an object does not extend the object" );
+ assert.equal( jQuery.data(obj)["test"], "in", "Verify setting an object on an object extends the data object" );
+ assert.equal( obj["test2"], undefined, "Verify setting an object on an object does not extend the object" );
// manually clean up detached elements
div.remove();
});
-test("jQuery.removeData", function() {
- expect(10);
+QUnit.test("jQuery.removeData", function( assert ) {
+ assert.expect(10);
var obj,
div = jQuery("#foo")[0];
jQuery.data(div, "test", "testing");
jQuery.removeData(div, "test");
- equal( jQuery.data(div, "test"), undefined, "Check removal of data" );
+ assert.equal( jQuery.data(div, "test"), undefined, "Check removal of data" );
jQuery.data(div, "test2", "testing");
jQuery.removeData( div );
- ok( !jQuery.data(div, "test2"), "Make sure that the data property no longer exists." );
- ok( !div[ jQuery.expando ], "Make sure the expando no longer exists, as well." );
+ assert.ok( !jQuery.data(div, "test2"), "Make sure that the data property no longer exists." );
+ assert.ok( !div[ jQuery.expando ], "Make sure the expando no longer exists, as well." );
jQuery.data(div, {
test3: "testing",
test4: "testing"
});
jQuery.removeData( div, "test3 test4" );
- ok( !jQuery.data(div, "test3") || jQuery.data(div, "test4"), "Multiple delete with spaces." );
+ assert.ok( !jQuery.data(div, "test3") || jQuery.data(div, "test4"), "Multiple delete with spaces." );
jQuery.data(div, {
test3: "testing",
test4: "testing"
});
jQuery.removeData( div, [ "test3", "test4" ] );
- ok( !jQuery.data(div, "test3") || jQuery.data(div, "test4"), "Multiple delete by array." );
+ assert.ok( !jQuery.data(div, "test3") || jQuery.data(div, "test4"), "Multiple delete by array." );
jQuery.data(div, {
"test3 test4": "testing",
"test3": "testing"
});
jQuery.removeData( div, "test3 test4" );
- ok( !jQuery.data(div, "test3 test4"), "Multiple delete with spaces deleted key with exact name" );
- ok( jQuery.data(div, "test3"), "Left the partial matched key alone" );
+ assert.ok( !jQuery.data(div, "test3 test4"), "Multiple delete with spaces deleted key with exact name" );
+ assert.ok( jQuery.data(div, "test3"), "Left the partial matched key alone" );
obj = {};
jQuery.data(obj, "test", "testing");
- equal( jQuery(obj).data("test"), "testing", "verify data on plain object");
+ assert.equal( jQuery(obj).data("test"), "testing", "verify data on plain object");
jQuery.removeData(obj, "test");
- equal( jQuery.data(obj, "test"), undefined, "Check removal of data on plain object" );
+ assert.equal( jQuery.data(obj, "test"), undefined, "Check removal of data on plain object" );
jQuery.data( window, "BAD", true );
jQuery.removeData( window, "BAD" );
- ok( !jQuery.data( window, "BAD" ), "Make sure that the value was not still set." );
+ assert.ok( !jQuery.data( window, "BAD" ), "Make sure that the value was not still set." );
});
-test(".removeData()", function() {
- expect(6);
+QUnit.test(".removeData()", function( assert ) {
+ assert.expect(6);
var div = jQuery("#foo");
div.data("test", "testing");
div.removeData("test");
- equal( div.data("test"), undefined, "Check removal of data" );
+ assert.equal( div.data("test"), undefined, "Check removal of data" );
div.data("test", "testing");
div.data("test.foo", "testing2");
div.removeData("test.bar");
- equal( div.data("test.foo"), "testing2", "Make sure data is intact" );
- equal( div.data("test"), "testing", "Make sure data is intact" );
+ assert.equal( div.data("test.foo"), "testing2", "Make sure data is intact" );
+ assert.equal( div.data("test"), "testing", "Make sure data is intact" );
div.removeData("test");
- equal( div.data("test.foo"), "testing2", "Make sure data is intact" );
- equal( div.data("test"), undefined, "Make sure data is intact" );
+ assert.equal( div.data("test.foo"), "testing2", "Make sure data is intact" );
+ assert.equal( div.data("test"), undefined, "Make sure data is intact" );
div.removeData("test.foo");
- equal( div.data("test.foo"), undefined, "Make sure data is intact" );
+ assert.equal( div.data("test.foo"), undefined, "Make sure data is intact" );
});
if (window.JSON && window.JSON.stringify) {
- test("JSON serialization (#8108)", function () {
- expect(1);
+ QUnit.test("JSON serialization (#8108)", function( assert ) {
+ assert.expect(1);
var obj = { "foo": "bar" };
jQuery.data(obj, "hidden", true);
- equal( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
+ assert.equal( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
});
}
-test(".data should follow html5 specification regarding camel casing", function() {
- expect(12);
+QUnit.test(".data should follow html5 specification regarding camel casing", function( assert ) {
+ assert.expect(12);
var div = jQuery("
")
.prependTo("body");
- equal( div.data()["wTF"], "ftw", "Verify single letter data-* key" );
- equal( div.data()["bigALittleA"], "bouncing-b", "Verify single letter mixed data-* key" );
+ assert.equal( div.data()["wTF"], "ftw", "Verify single letter data-* key" );
+ assert.equal( div.data()["bigALittleA"], "bouncing-b", "Verify single letter mixed data-* key" );
- equal( div.data()["foo"], "a", "Verify single word data-* key" );
- equal( div.data()["fooBar"], "b", "Verify multiple word data-* key" );
- equal( div.data()["fooBarBaz"], "c", "Verify multiple word data-* key" );
+ assert.equal( div.data()["foo"], "a", "Verify single word data-* key" );
+ assert.equal( div.data()["fooBar"], "b", "Verify multiple word data-* key" );
+ assert.equal( div.data()["fooBarBaz"], "c", "Verify multiple word data-* key" );
- equal( div.data("foo"), "a", "Verify single word data-* key" );
- equal( div.data("fooBar"), "b", "Verify multiple word data-* key" );
- equal( div.data("fooBarBaz"), "c", "Verify multiple word data-* key" );
+ assert.equal( div.data("foo"), "a", "Verify single word data-* key" );
+ assert.equal( div.data("fooBar"), "b", "Verify multiple word data-* key" );
+ assert.equal( div.data("fooBarBaz"), "c", "Verify multiple word data-* key" );
div.data("foo-bar", "d");
- equal( div.data("fooBar"), "d", "Verify updated data-* key" );
- equal( div.data("foo-bar"), "d", "Verify updated data-* key" );
+ assert.equal( div.data("fooBar"), "d", "Verify updated data-* key" );
+ assert.equal( div.data("foo-bar"), "d", "Verify updated data-* key" );
- equal( div.data("fooBar"), "d", "Verify updated data-* key (fooBar)" );
- equal( div.data("foo-bar"), "d", "Verify updated data-* key (foo-bar)" );
+ assert.equal( div.data("fooBar"), "d", "Verify updated data-* key (fooBar)" );
+ assert.equal( div.data("foo-bar"), "d", "Verify updated data-* key (foo-bar)" );
div.remove();
});
-test(".data should not miss preset data-* w/ hyphenated property names", function() {
+QUnit.test(".data should not miss preset data-* w/ hyphenated property names", function( assert ) {
- expect(2);
+ assert.expect(2);
var div = jQuery("
", { id: "hyphened" }).appendTo("#qunit-fixture"),
test = {
@@ -565,23 +565,23 @@ test(".data should not miss preset data-* w/ hyphenated property names", functio
div.data( test );
jQuery.each( test , function(i, k) {
- equal( div.data(k), k, "data with property '"+k+"' was correctly found");
+ assert.equal( div.data(k), k, "data with property '"+k+"' was correctly found");
});
});
-test("jQuery.data should not miss data-* w/ hyphenated property names #14047", function() {
+QUnit.test("jQuery.data should not miss data-* w/ hyphenated property names #14047", function( assert ) {
- expect(1);
+ assert.expect(1);
var div = jQuery("
");
div.data( "foo-bar", "baz" );
- equal( jQuery.data(div[0], "foo-bar"), "baz", "data with property 'foo-bar' was correctly found");
+ assert.equal( jQuery.data(div[0], "foo-bar"), "baz", "data with property 'foo-bar' was correctly found");
});
-test(".data should not miss attr() set data-* with hyphenated property names", function() {
- expect(2);
+QUnit.test(".data should not miss attr() set data-* with hyphenated property names", function( assert ) {
+ assert.expect(2);
var a, b;
@@ -590,7 +590,7 @@ test(".data should not miss attr() set data-* with hyphenated property names", f
a.attr( "data-long-param", "test" );
a.data( "long-param", { a: 2 });
- deepEqual( a.data("long-param"), { a: 2 }, "data with property long-param was found, 1" );
+ assert.deepEqual( a.data("long-param"), { a: 2 }, "data with property long-param was found, 1" );
b = jQuery("
").appendTo("#qunit-fixture");
@@ -598,11 +598,11 @@ test(".data should not miss attr() set data-* with hyphenated property names", f
b.data( "long-param" );
b.data( "long-param", { a: 2 });
- deepEqual( b.data("long-param"), { a: 2 }, "data with property long-param was found, 2" );
+ assert.deepEqual( b.data("long-param"), { a: 2 }, "data with property long-param was found, 2" );
});
-test(".data always sets data with the camelCased key (gh-2257)", function() {
- expect( 18 );
+QUnit.test(".data always sets data with the camelCased key (gh-2257)", function( assert ) {
+ assert.expect( 18 );
var div = jQuery("").appendTo("#qunit-fixture"),
datas = {
@@ -624,22 +624,22 @@ test(".data always sets data with the camelCased key (gh-2257)", function() {
jQuery.each( datas, function( key, val ) {
div.data( key, val );
var allData = div.data();
- equal( allData[ key ], undefined, ".data does not store with hyphenated keys" );
- equal( allData[ jQuery.camelCase( key ) ], val, ".data stores the camelCased key" );
+ assert.equal( allData[ key ], undefined, ".data does not store with hyphenated keys" );
+ assert.equal( allData[ jQuery.camelCase( key ) ], val, ".data stores the camelCased key" );
});
});
-test( ".data should not strip more than one hyphen when camelCasing (gh-2070)", function() {
- expect( 3 );
+QUnit.test( ".data should not strip more than one hyphen when camelCasing (gh-2070)", function( assert ) {
+ assert.expect( 3 );
var div = jQuery( "
" ).appendTo( "#qunit-fixture" ),
allData = div.data();
- equal( allData.nestedSingle, "single", "Key is correctly camelCased" );
- equal( allData[ "nested-Double" ], "double", "Key with double hyphens is correctly camelCased" );
- equal( allData[ "nested--Triple" ], "triple", "Key with triple hyphens is correctly camelCased" );
+ assert.equal( allData.nestedSingle, "single", "Key is correctly camelCased" );
+ assert.equal( allData[ "nested-Double" ], "double", "Key with double hyphens is correctly camelCased" );
+ assert.equal( allData[ "nested--Triple" ], "triple", "Key with triple hyphens is correctly camelCased" );
});
-test(".data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {
+QUnit.test(".data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function( assert ) {
var div = jQuery("
", { id: "hyphened" }).appendTo("#qunit-fixture"),
datas = {
@@ -660,17 +660,17 @@ test(".data supports interoperable hyphenated/camelCase get/set of properties wi
"2-num-start": true
};
- expect( 24 );
+ assert.expect( 24 );
jQuery.each( datas, function( key, val ) {
div.data( key, val );
- deepEqual( div.data( key ), val, "get: " + key );
- deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
+ assert.deepEqual( div.data( key ), val, "get: " + key );
+ assert.deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
});
});
-test(".data supports interoperable removal of hyphenated/camelCase properties", function() {
+QUnit.test(".data supports interoperable removal of hyphenated/camelCase properties", function( assert ) {
var div = jQuery("
", { id: "hyphened" }).appendTo("#qunit-fixture"),
datas = {
"non-empty": "a string",
@@ -687,22 +687,22 @@ test(".data supports interoperable removal of hyphenated/camelCase properties",
"some-json": "{ \"foo\": \"bar\" }"
};
- expect( 27 );
+ assert.expect( 27 );
jQuery.each( datas, function( key, val ) {
div.data( key, val );
- deepEqual( div.data( key ), val, "get: " + key );
- deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
+ assert.deepEqual( div.data( key ), val, "get: " + key );
+ assert.deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
div.removeData( key );
- equal( div.data( key ), undefined, "get: " + key );
+ assert.equal( div.data( key ), undefined, "get: " + key );
});
});
-test(".data supports interoperable removal of properties SET TWICE #13850", function() {
+QUnit.test(".data supports interoperable removal of properties SET TWICE #13850", function( assert ) {
var div = jQuery("
").appendTo("#qunit-fixture"),
datas = {
"non-empty": "a string",
@@ -719,7 +719,7 @@ test(".data supports interoperable removal of properties SET TWICE #13850", func
"some-json": "{ \"foo\": \"bar\" }"
};
- expect( 9 );
+ assert.expect( 9 );
jQuery.each( datas, function( key, val ) {
div.data( key, val );
@@ -727,12 +727,12 @@ test(".data supports interoperable removal of properties SET TWICE #13850", func
div.removeData( key );
- equal( div.data( key ), undefined, "removal: " + key );
+ assert.equal( div.data( key ), undefined, "removal: " + key );
});
});
-test( ".removeData supports removal of hyphenated properties via array (#12786, gh-2257)", function() {
- expect( 4 );
+QUnit.test( ".removeData supports removal of hyphenated properties via array (#12786, gh-2257)", function( assert ) {
+ assert.expect( 4 );
var div, plain, compare;
@@ -751,31 +751,31 @@ test( ".removeData supports removal of hyphenated properties via array (#12786,
div.data({ "a-a": 1 }).data( "b-b", 1 );
plain.data({ "a-a": 1 }).data( "b-b", 1 );
- deepEqual( div.data(), compare, "Data appears as expected. (div)" );
- deepEqual( plain.data(), compare, "Data appears as expected. (plain)" );
+ assert.deepEqual( div.data(), compare, "Data appears as expected. (div)" );
+ assert.deepEqual( plain.data(), compare, "Data appears as expected. (plain)" );
div.removeData([ "a-a", "b-b" ]);
plain.removeData([ "a-a", "b-b" ]);
- deepEqual( div.data(), {}, "Data is empty. (div)" );
- deepEqual( plain.data(), {}, "Data is empty. (plain)" );
+ assert.deepEqual( div.data(), {}, "Data is empty. (div)" );
+ assert.deepEqual( plain.data(), {}, "Data is empty. (plain)" );
});
// Test originally by Moschel
-test(".removeData should not throw exceptions. (#10080)", function() {
- expect(1);
- stop();
+QUnit.test(".removeData should not throw exceptions. (#10080)", function( assert ) {
+ assert.expect(1);
+ QUnit.stop();
var frame = jQuery("#loadediframe");
jQuery(frame[0].contentWindow).on("unload", function() {
- ok(true, "called unload");
- start();
+ assert.ok(true, "called unload");
+ QUnit.start();
});
// change the url to trigger unload
frame.attr("src", "data/iframe.html?param=true");
});
-test( ".data only checks element attributes once. #8909", function() {
- expect( 2 );
+QUnit.test( ".data only checks element attributes once. #8909", function( assert ) {
+ assert.expect( 2 );
var testing = {
"test": "testing",
"test2": "testing"
@@ -785,63 +785,63 @@ test( ".data only checks element attributes once. #8909", function() {
// set an attribute using attr to ensure it
node.setAttribute( "data-test2", "testing" );
- deepEqual( element.data(), testing, "Sanity Check" );
+ assert.deepEqual( element.data(), testing, "Sanity Check" );
node.setAttribute( "data-test3", "testing" );
- deepEqual( element.data(), testing, "The data didn't change even though the data-* attrs did" );
+ assert.deepEqual( element.data(), testing, "The data didn't change even though the data-* attrs did" );
// clean up data cache
element.remove();
});
-test( "data-* with JSON value can have newlines", function() {
- expect(1);
+QUnit.test( "data-* with JSON value can have newlines", function( assert ) {
+ assert.expect(1);
var x = jQuery("
");
- equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" );
+ assert.equal( x.data("some").foo, "bar", "got a JSON data- attribute with spaces" );
x.remove();
});
-test(".data doesn't throw when calling selection is empty. #13551", function() {
- expect(1);
+QUnit.test(".data doesn't throw when calling selection is empty. #13551", function( assert ) {
+ assert.expect(1);
try {
jQuery( null ).data( "prop" );
- ok( true, "jQuery(null).data('prop') does not throw" );
+ assert.ok( true, "jQuery(null).data('prop') does not throw" );
} catch ( e ) {
- ok( false, e.message );
+ assert.ok( false, e.message );
}
});
-test("jQuery.acceptData", function() {
- expect( 10 );
+QUnit.test("jQuery.acceptData", function( assert ) {
+ assert.expect( 10 );
var flash, pdf;
- ok( jQuery.acceptData( document ), "document" );
- ok( jQuery.acceptData( document.documentElement ), "documentElement" );
- ok( jQuery.acceptData( {} ), "object" );
- ok( jQuery.acceptData( document.createElement( "embed" ) ), "embed" );
+ assert.ok( jQuery.acceptData( document ), "document" );
+ assert.ok( jQuery.acceptData( document.documentElement ), "documentElement" );
+ assert.ok( jQuery.acceptData( {} ), "object" );
+ assert.ok( jQuery.acceptData( document.createElement( "embed" ) ), "embed" );
flash = document.createElement( "object" );
flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" );
- ok( jQuery.acceptData( flash ), "flash" );
+ assert.ok( jQuery.acceptData( flash ), "flash" );
pdf = document.createElement( "object" );
pdf.setAttribute( "classid", "clsid:CA8A9780-280D-11CF-A24D-444553540000" );
- ok( jQuery.acceptData( pdf ), "pdf" );
+ assert.ok( jQuery.acceptData( pdf ), "pdf" );
- ok( !jQuery.acceptData( document.createComment( "" ) ), "comment" );
- ok( !jQuery.acceptData( document.createTextNode( "" ) ), "text" );
- ok( !jQuery.acceptData( document.createDocumentFragment() ), "documentFragment" );
+ assert.ok( !jQuery.acceptData( document.createComment( "" ) ), "comment" );
+ assert.ok( !jQuery.acceptData( document.createTextNode( "" ) ), "text" );
+ assert.ok( !jQuery.acceptData( document.createDocumentFragment() ), "documentFragment" );
- ok( jQuery.acceptData(
+ assert.ok( jQuery.acceptData(
jQuery( "#form" ).append( "
" )[ 0 ] ),
"form with aliased DOM properties" );
});
-test("Check proper data removal of non-element descendants nodes (#8335)", function() {
- expect( 1 );
+QUnit.test("Check proper data removal of non-element descendants nodes (#8335)", function( assert ) {
+ assert.expect( 1 );
var div = jQuery("
text
"),
text = div.contents();
@@ -849,28 +849,31 @@ test("Check proper data removal of non-element descendants nodes (#8335)", funct
text.data( "test", "test" ); // This should be a noop.
div.remove();
- ok( !text.data("test"), "Be sure data is not stored in non-element" );
+ assert.ok( !text.data("test"), "Be sure data is not stored in non-element" );
});
-testIframeWithCallback( "enumerate data attrs on body (#14894)", "data/dataAttrs.html", function( result ) {
- expect( 1 );
+testIframeWithCallback(
+ "enumerate data attrs on body (#14894)",
+ "data/dataAttrs.html",
+ function( result, assert ) {
+ assert.expect( 1 );
+ assert.equal( result, "ok", "enumeration of data- attrs on body" );
+ }
+);
- equal( result, "ok", "enumeration of data- attrs on body" );
-});
-
-test( "Check that the expando is removed when there's no more data", function() {
- expect( 1 );
+QUnit.test( "Check that the expando is removed when there's no more data", function( assert ) {
+ assert.expect( 1 );
var key,
div = jQuery( "
" );
div.data( "some", "data" );
- equal( div.data( "some" ), "data", "Data is added" );
+ assert.equal( div.data( "some" ), "data", "Data is added" );
div.removeData( "some" );
// Make sure the expando is gone
for ( key in div[ 0 ] ) {
if ( /^jQuery/.test( key ) ) {
- 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" );
}
}
});
diff --git a/test/unit/deferred.js b/test/unit/deferred.js
index 1aa15435f..83b7897af 100644
--- a/test/unit/deferred.js
+++ b/test/unit/deferred.js
@@ -1,4 +1,4 @@
-module( "deferred", {
+QUnit.module( "deferred", {
teardown: moduleTeardown
});
@@ -8,51 +8,51 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
return withNew ? new jQuery.Deferred( fn ) : jQuery.Deferred( fn );
}
- test( "jQuery.Deferred" + withNew, function() {
+ QUnit.test( "jQuery.Deferred" + withNew, function( assert ) {
- expect( 23 );
+ assert.expect( 23 );
var defer = createDeferred();
- ok( jQuery.isFunction( defer.pipe ), "defer.pipe is a function" );
+ assert.ok( jQuery.isFunction( defer.pipe ), "defer.pipe is a function" );
createDeferred().resolve().done(function() {
- ok( true, "Success on resolve" );
- strictEqual( this.state(), "resolved", "Deferred is resolved (state)" );
+ assert.ok( true, "Success on resolve" );
+ assert.strictEqual( this.state(), "resolved", "Deferred is resolved (state)" );
}).fail(function() {
- ok( false, "Error on resolve" );
+ assert.ok( false, "Error on resolve" );
}).always(function() {
- ok( true, "Always callback on resolve" );
+ assert.ok( true, "Always callback on resolve" );
});
createDeferred().reject().done(function() {
- ok( false, "Success on reject" );
+ assert.ok( false, "Success on reject" );
}).fail(function() {
- ok( true, "Error on reject" );
- strictEqual( this.state(), "rejected", "Deferred is rejected (state)" );
+ assert.ok( true, "Error on reject" );
+ assert.strictEqual( this.state(), "rejected", "Deferred is rejected (state)" );
}).always(function() {
- ok( true, "Always callback on reject" );
+ assert.ok( true, "Always callback on reject" );
});
createDeferred(function( defer ) {
- ok( this === defer, "Defer passed as this & first argument" );
+ assert.ok( this === defer, "Defer passed as this & first argument" );
this.resolve("done");
}).done(function( value ) {
- strictEqual( value, "done", "Passed function executed" );
+ assert.strictEqual( value, "done", "Passed function executed" );
});
createDeferred(function( defer ) {
var promise = defer.promise(),
func = function() {},
funcPromise = defer.promise( func );
- strictEqual( defer.promise(), promise, "promise is always the same" );
- strictEqual( funcPromise, func, "non objects get extended" );
+ assert.strictEqual( defer.promise(), promise, "promise is always the same" );
+ assert.strictEqual( funcPromise, func, "non objects get extended" );
jQuery.each( promise, function( key ) {
if ( !jQuery.isFunction( promise[ key ] ) ) {
- ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" );
+ assert.ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" );
}
if ( promise[ key ] !== func[ key ] ) {
- strictEqual( func[ key ], promise[ key ], key + " is the same" );
+ assert.strictEqual( func[ key ], promise[ key ], key + " is the same" );
}
});
});
@@ -60,17 +60,17 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
jQuery.expandedEach = jQuery.each;
jQuery.expandedEach( "resolve reject".split(" "), function( _, change ) {
createDeferred(function( defer ) {
- strictEqual( defer.state(), "pending", "pending after creation" );
+ assert.strictEqual( defer.state(), "pending", "pending after creation" );
var checked = 0;
defer.progress(function( value ) {
- strictEqual( value, checked, "Progress: right value (" + value + ") received" );
+ assert.strictEqual( value, checked, "Progress: right value (" + value + ") received" );
});
for ( checked = 0; checked < 3; checked++ ) {
defer.notify( checked );
}
- strictEqual( defer.state(), "pending", "pending after notification" );
+ assert.strictEqual( defer.state(), "pending", "pending after notification" );
defer[ change ]();
- notStrictEqual( defer.state(), "pending", "not pending after " + change );
+ assert.notStrictEqual( defer.state(), "pending", "not pending after " + change );
defer.notify();
});
});
@@ -78,22 +78,22 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
});
-test( "jQuery.Deferred - chainability", function() {
+QUnit.test( "jQuery.Deferred - chainability", function( assert ) {
var defer = jQuery.Deferred();
- expect( 10 );
+ assert.expect( 10 );
jQuery.expandedEach = jQuery.each;
jQuery.expandedEach( "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split(" "), function( _, method ) {
var object = {
m: defer[ method ]
};
- strictEqual( object.m(), object, method + " is chainable" );
+ assert.strictEqual( object.m(), object, method + " is chainable" );
});
});
-test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
+QUnit.test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
assert.expect( 4 );
@@ -130,7 +130,7 @@ test( "jQuery.Deferred.then - filtering (done)", function( assert ) {
});
});
-test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
+QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
assert.expect( 4 );
@@ -167,7 +167,7 @@ test( "jQuery.Deferred.then - filtering (fail)", function( assert ) {
});
});
-test( "jQuery.Deferred.catch", function( assert ) {
+QUnit.test( "jQuery.Deferred.catch", function( assert ) {
assert.expect( 4 );
var value1, value2, value3,
@@ -203,7 +203,7 @@ test( "jQuery.Deferred.catch", function( assert ) {
});
});
-test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) {
+QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) {
assert.expect( 4 );
@@ -240,7 +240,7 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert )
});
});
-test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
+QUnit.test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
assert.expect( 3 );
@@ -268,7 +268,7 @@ test( "jQuery.Deferred.then - filtering (progress)", function( assert ) {
});
});
-test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
+QUnit.test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
assert.expect( 3 );
@@ -300,7 +300,7 @@ test( "jQuery.Deferred.then - deferred (done)", function( assert ) {
});
});
-test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
+QUnit.test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
assert.expect( 3 );
@@ -332,7 +332,7 @@ test( "jQuery.Deferred.then - deferred (fail)", function( assert ) {
});
});
-test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
+QUnit.test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
assert.expect( 3 );
@@ -372,7 +372,7 @@ test( "jQuery.Deferred.then - deferred (progress)", function( assert ) {
});
});
-test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert ) {
+QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert ) {
assert.expect( 3 );
@@ -404,7 +404,7 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert
});
});
-test( "jQuery.Deferred.then - context", function( assert ) {
+QUnit.test( "jQuery.Deferred.then - context", function( assert ) {
assert.expect( 7 );
@@ -455,7 +455,7 @@ test( "jQuery.Deferred.then - context", function( assert ) {
});
});
-test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
+QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
assert.expect( 7 );
@@ -506,9 +506,9 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) {
});
});
-asyncTest( "jQuery.Deferred.then - spec compatibility", function() {
+QUnit.asyncTest( "jQuery.Deferred.then - spec compatibility", function( assert ) {
- expect( 1 );
+ assert.expect( 1 );
var defer = jQuery.Deferred().done(function() {
setTimeout( start );
@@ -516,7 +516,7 @@ asyncTest( "jQuery.Deferred.then - spec compatibility", function() {
});
defer.then(function() {
- ok( true, "errors in .done callbacks don't stop .then handlers" );
+ assert.ok( true, "errors in .done callbacks don't stop .then handlers" );
});
try {
@@ -524,9 +524,9 @@ asyncTest( "jQuery.Deferred.then - spec compatibility", function() {
} catch ( _ ) {}
});
-test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
+QUnit.test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
- expect( 8 );
+ assert.expect( 8 );
var context = { id: "callback context" },
thenable = jQuery.Deferred().resolve( "thenable fulfillment" ).promise(),
@@ -575,16 +575,16 @@ test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) {
});
});
-test( "jQuery.Deferred.then - progress and thenables", function( assert ) {
+QUnit.test( "jQuery.Deferred.then - progress and thenables", function( assert ) {
- expect( 2 );
+ assert.expect( 2 );
var trigger = jQuery.Deferred().notify(),
expectedProgress = [ "baz", "baz" ],
done = jQuery.map( new Array( 2 ), function() { return assert.async(); } ),
failer = function( evt ) {
return function() {
- ok( false, "no unexpected " + evt );
+ assert.ok( false, "no unexpected " + evt );
};
};
@@ -601,9 +601,9 @@ test( "jQuery.Deferred.then - progress and thenables", function( assert ) {
trigger.notify();
});
-test( "jQuery.Deferred - notify and resolve", function( assert ) {
+QUnit.test( "jQuery.Deferred - notify and resolve", function( assert ) {
- expect( 7 );
+ assert.expect( 7 );
var notifiedResolved = jQuery.Deferred().notify( "foo" )/*xxx .resolve( "bar" )*/,
done = jQuery.map( new Array( 3 ), function() { return assert.async(); } );
@@ -649,9 +649,9 @@ test( "jQuery.Deferred - notify and resolve", function( assert ) {
} );
});
-test( "jQuery.when", function() {
+QUnit.test( "jQuery.when", function( assert ) {
- expect( 37 );
+ assert.expect( 37 );
// Some other objects
jQuery.each({
@@ -667,22 +667,22 @@ test( "jQuery.when", function() {
"an array": [ 1, 2, 3 ]
}, function( message, value ) {
- ok(
+ assert.ok(
jQuery.isFunction(
jQuery.when( value ).done(function( resolveValue ) {
- strictEqual( this, window, "Context is the global object with " + message );
- strictEqual( resolveValue, value, "Test the promise was resolved with " + message );
+ assert.strictEqual( this, window, "Context is the global object with " + message );
+ assert.strictEqual( resolveValue, value, "Test the promise was resolved with " + message );
}).promise
),
"Test " + message + " triggers the creation of a new Promise"
);
});
- ok(
+ assert.ok(
jQuery.isFunction(
jQuery.when().done(function( resolveValue ) {
- strictEqual( this, window, "Test the promise was resolved with window as its context" );
- strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" );
+ assert.strictEqual( this, window, "Test the promise was resolved with window as its context" );
+ assert.strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" );
}).promise
),
"Test calling when with no parameter triggers the creation of a new Promise"
@@ -692,7 +692,7 @@ test( "jQuery.when", function() {
context = {};
jQuery.when( jQuery.Deferred().resolveWith( context ) ).done(function() {
- strictEqual( this, context, "when( promise ) propagates context" );
+ assert.strictEqual( this, context, "when( promise ) propagates context" );
});
jQuery.each([ 1, 2, 3 ], function( k, i ) {
@@ -702,16 +702,16 @@ test( "jQuery.when", function() {
})
).done(function( value ) {
- strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) );
+ assert.strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) );
cache = value;
});
});
});
-test( "jQuery.when - joined", function() {
+QUnit.test( "jQuery.when - joined", function( assert ) {
- expect( 195 );
+ assert.expect( 195 );
var deferreds = {
rawValue: 1,
@@ -741,11 +741,11 @@ test( "jQuery.when - joined", function() {
},
counter = 49;
- stop();
+ QUnit.stop();
function restart() {
if ( !--counter ) {
- start();
+ QUnit.start();
}
}
@@ -764,22 +764,22 @@ test( "jQuery.when - joined", function() {
jQuery.when( defer1, defer2 ).done(function( a, b ) {
if ( shouldResolve ) {
- deepEqual( [ a, b ], expected, code + " => resolve" );
- strictEqual( this[ 0 ], context1, code + " => first context OK" );
- strictEqual( this[ 1 ], context2, code + " => second context OK" );
+ assert.deepEqual( [ a, b ], expected, code + " => resolve" );
+ assert.strictEqual( this[ 0 ], context1, code + " => first context OK" );
+ assert.strictEqual( this[ 1 ], context2, code + " => second context OK" );
} else {
- ok( false, code + " => resolve" );
+ assert.ok( false, code + " => resolve" );
}
}).fail(function( a, b ) {
if ( shouldError ) {
- deepEqual( [ a, b ], expected, code + " => reject" );
+ assert.deepEqual( [ a, b ], expected, code + " => reject" );
} else {
- ok( false, code + " => reject" );
+ assert.ok( false, code + " => reject" );
}
}).progress(function( a, b ) {
- deepEqual( [ a, b ], expectedNotify, code + " => progress" );
- strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" );
- strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" );
+ assert.deepEqual( [ a, b ], expectedNotify, code + " => progress" );
+ assert.strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" );
+ assert.strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" );
}).always( restart );
});
});
@@ -787,69 +787,69 @@ test( "jQuery.when - joined", function() {
deferreds.eventuallyRejected.reject( 0 );
});
-test( "jQuery.when - resolved", function() {
+QUnit.test( "jQuery.when - resolved", function( assert ) {
- expect( 6 );
+ assert.expect( 6 );
var a = jQuery.Deferred().notify( 1 ).resolve( 4 ),
b = jQuery.Deferred().notify( 2 ).resolve( 5 ),
c = jQuery.Deferred().notify( 3 ).resolve( 6 );
jQuery.when( a, b, c ).progress(function( a, b, c ) {
- strictEqual( a, 1, "first notify value ok" );
- strictEqual( b, 2, "second notify value ok" );
- strictEqual( c, 3, "third notify value ok" );
+ assert.strictEqual( a, 1, "first notify value ok" );
+ assert.strictEqual( b, 2, "second notify value ok" );
+ assert.strictEqual( c, 3, "third notify value ok" );
}).done(function( a, b, c ) {
- strictEqual( a, 4, "first resolve value ok" );
- strictEqual( b, 5, "second resolve value ok" );
- strictEqual( c, 6, "third resolve value ok" );
+ assert.strictEqual( a, 4, "first resolve value ok" );
+ assert.strictEqual( b, 5, "second resolve value ok" );
+ assert.strictEqual( c, 6, "third resolve value ok" );
}).fail(function() {
- ok( false, "Error on resolve" );
+ assert.ok( false, "Error on resolve" );
});
});
-test( "jQuery.when - filtering", function() {
+QUnit.test( "jQuery.when - filtering", function( assert ) {
- expect( 2 );
+ assert.expect( 2 );
function increment( x ) {
return x + 1;
}
- stop();
+ QUnit.stop();
jQuery.when(
jQuery.Deferred().resolve( 3 ).then( increment ),
jQuery.Deferred().reject( 5 ).then( null, increment )
).done(function( four, six ) {
- strictEqual( four, 4, "resolved value incremented" );
- strictEqual( six, 6, "rejected value incremented" );
- start();
+ assert.strictEqual( four, 4, "resolved value incremented" );
+ assert.strictEqual( six, 6, "rejected value incremented" );
+ QUnit.start();
});
});
-test( "jQuery.when - exceptions", function() {
+QUnit.test( "jQuery.when - exceptions", function( assert ) {
- expect( 2 );
+ assert.expect( 2 );
function woops() {
throw "exception thrown";
}
- stop();
+ QUnit.stop();
jQuery.Deferred().resolve().then( woops ).fail(function( doneException ) {
- strictEqual( doneException, "exception thrown", "throwing in done handler" );
+ assert.strictEqual( doneException, "exception thrown", "throwing in done handler" );
jQuery.Deferred().reject().then( null, woops ).fail(function( failException ) {
- strictEqual( failException, "exception thrown", "throwing in fail handler" );
- start();
+ assert.strictEqual( failException, "exception thrown", "throwing in fail handler" );
+ QUnit.start();
});
});
});
-test( "jQuery.when - chaining", function() {
+QUnit.test( "jQuery.when - chaining", function( assert ) {
- expect( 4 );
+ assert.expect( 4 );
var defer = jQuery.Deferred();
@@ -861,7 +861,7 @@ test( "jQuery.when - chaining", function() {
return Promise.resolve( "std deferred" );
}
- stop();
+ QUnit.stop();
jQuery.when(
jQuery.Deferred().resolve( 3 ).then( chain ),
@@ -869,11 +869,11 @@ test( "jQuery.when - chaining", function() {
jQuery.Deferred().resolve( 3 ).then( chainStandard ),
jQuery.Deferred().reject( 5 ).then( null, chainStandard )
).done(function( v1, v2, s1, s2 ) {
- strictEqual( v1, "other deferred", "chaining in done handler" );
- strictEqual( v2, "other deferred", "chaining in fail handler" );
- strictEqual( s1, "std deferred", "chaining thenable in done handler" );
- strictEqual( s2, "std deferred", "chaining thenable in fail handler" );
- start();
+ assert.strictEqual( v1, "other deferred", "chaining in done handler" );
+ assert.strictEqual( v2, "other deferred", "chaining in fail handler" );
+ assert.strictEqual( s1, "std deferred", "chaining thenable in done handler" );
+ assert.strictEqual( s2, "std deferred", "chaining thenable in fail handler" );
+ QUnit.start();
});
defer.resolve( "other deferred" );
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index 9dcad77e4..2a2357a52 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.js
@@ -1,2 +1,2 @@
-module("deprecated", { teardown: moduleTeardown });
+QUnit.module("deprecated", { teardown: moduleTeardown });
diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js
index 72327e011..5b471094f 100644
--- a/test/unit/dimensions.js
+++ b/test/unit/dimensions.js
@@ -4,7 +4,7 @@ if ( !jQuery.fn.width ) {
return;
}
-module("dimensions", { teardown: moduleTeardown });
+QUnit.module("dimensions", { teardown: moduleTeardown });
function pass( val ) {
return val;
@@ -21,127 +21,127 @@ function fn( val ) {
pass and fn can be used to test passing functions to setters
See testWidth below for an example
- pass( value );
+ pass( value, assert );
This function returns whatever value is passed in
- fn( value );
+ fn( value, assert );
Returns a function that returns the value
*/
-function testWidth( val ) {
- expect(9);
+function testWidth( val, assert ) {
+ assert.expect(9);
var $div, blah;
$div = jQuery("#nothiddendiv");
$div.width( val(30) );
- equal($div.width(), 30, "Test set to 30 correctly");
+ assert.equal($div.width(), 30, "Test set to 30 correctly");
$div.hide();
- equal($div.width(), 30, "Test hidden div");
+ assert.equal($div.width(), 30, "Test hidden div");
$div.show();
$div.width( val(-1) ); // handle negative numbers by setting to 0 #11604
- equal($div.width(), 0, "Test negative width normalized to 0");
+ assert.equal($div.width(), 0, "Test negative width normalized to 0");
$div.css("padding", "20px");
- equal($div.width(), 0, "Test padding specified with pixels");
+ assert.equal($div.width(), 0, "Test padding specified with pixels");
$div.css("border", "2px solid #fff");
- equal($div.width(), 0, "Test border specified with pixels");
+ assert.equal($div.width(), 0, "Test border specified with pixels");
$div.css({ "display": "", "border": "", "padding": "" });
jQuery("#nothiddendivchild").css({ "width": 20, "padding": "3px", "border": "2px solid #fff" });
- equal(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
+ assert.equal(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "width": "" });
blah = jQuery("blah");
- equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
- equal( blah.width(), null, "Make sure 'null' is returned on an empty set");
+ assert.equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
+ assert.equal( blah.width(), null, "Make sure 'null' is returned on an empty set");
- equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
+ assert.equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
QUnit.expectJqData( this, $div[0], "olddisplay" );
}
-test("width()", function() {
- testWidth( pass );
+QUnit.test("width()", function( assert ) {
+ testWidth( pass, assert );
});
-test("width(Function)", function() {
- testWidth( fn );
+QUnit.test("width(Function)", function( assert ) {
+ testWidth( fn, assert );
});
-test("width(Function(args))", function() {
- expect( 2 );
+QUnit.test("width(Function(args))", function( assert ) {
+ assert.expect( 2 );
var $div = jQuery("#nothiddendiv");
$div.width( 30 ).width(function(i, width) {
- equal( width, 30, "Make sure previous value is correct." );
+ assert.equal( width, 30, "Make sure previous value is correct." );
return width + 1;
});
- equal( $div.width(), 31, "Make sure value was modified correctly." );
+ assert.equal( $div.width(), 31, "Make sure value was modified correctly." );
});
-function testHeight( val ) {
- expect(9);
+function testHeight( val, assert ) {
+ assert.expect(9);
var $div, blah;
$div = jQuery("#nothiddendiv");
$div.height( val(30) );
- equal($div.height(), 30, "Test set to 30 correctly");
+ assert.equal($div.height(), 30, "Test set to 30 correctly");
$div.hide();
- equal($div.height(), 30, "Test hidden div");
+ assert.equal($div.height(), 30, "Test hidden div");
$div.show();
$div.height( val(-1) ); // handle negative numbers by setting to 0 #11604
- equal($div.height(), 0, "Test negative height normalized to 0");
+ assert.equal($div.height(), 0, "Test negative height normalized to 0");
$div.css("padding", "20px");
- equal($div.height(), 0, "Test padding specified with pixels");
+ assert.equal($div.height(), 0, "Test padding specified with pixels");
$div.css("border", "2px solid #fff");
- equal($div.height(), 0, "Test border specified with pixels");
+ assert.equal($div.height(), 0, "Test border specified with pixels");
$div.css({ "display": "", "border": "", "padding": "", "height": "1px" });
jQuery("#nothiddendivchild").css({ "height": 20, "padding": "3px", "border": "2px solid #fff" });
- equal(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
+ assert.equal(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "height": "" });
blah = jQuery("blah");
- equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
- equal( blah.height(), null, "Make sure 'null' is returned on an empty set");
+ assert.equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
+ assert.equal( blah.height(), null, "Make sure 'null' is returned on an empty set");
- equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
+ assert.equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
QUnit.expectJqData( this, $div[0], "olddisplay" );
}
-test("height()", function() {
- testHeight( pass );
+QUnit.test("height()", function( assert ) {
+ testHeight( pass, assert );
});
-test("height(Function)", function() {
- testHeight( fn );
+QUnit.test("height(Function)", function( assert ) {
+ testHeight( fn, assert );
});
-test("height(Function(args))", function() {
- expect( 2 );
+QUnit.test("height(Function(args))", function( assert ) {
+ assert.expect( 2 );
var $div = jQuery("#nothiddendiv");
$div.height( 30 ).height(function(i, height) {
- equal( height, 30, "Make sure previous value is correct." );
+ assert.equal( height, 30, "Make sure previous value is correct." );
return height + 1;
});
- equal( $div.height(), 31, "Make sure value was modified correctly." );
+ assert.equal( $div.height(), 31, "Make sure value was modified correctly." );
});
-test("innerWidth()", function() {
- expect( 6 );
+QUnit.test("innerWidth()", function( assert ) {
+ assert.expect( 6 );
var $div, div,
$win = jQuery( window ),
$doc = jQuery( document );
- equal( jQuery( window ).innerWidth(), $win.width(), "Test on window" );
- equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" );
+ assert.equal( jQuery( window ).innerWidth(), $win.width(), "Test on window" );
+ assert.equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" );
$div = jQuery( "#nothiddendiv" );
$div.css({
@@ -150,11 +150,11 @@ test("innerWidth()", function() {
"width": 30
});
- equal( $div.innerWidth(), 30, "Test with margin and border" );
+ assert.equal( $div.innerWidth(), 30, "Test with margin and border" );
$div.css( "padding", "20px" );
- equal( $div.innerWidth(), 70, "Test with margin, border and padding" );
+ assert.equal( $div.innerWidth(), 70, "Test with margin, border and padding" );
$div.hide();
- equal( $div.innerWidth(), 70, "Test hidden div" );
+ assert.equal( $div.innerWidth(), 70, "Test hidden div" );
// reset styles
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
@@ -162,21 +162,21 @@ test("innerWidth()", function() {
div = jQuery( "
" );
// Temporarily require 0 for backwards compat - should be auto
- equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
+ assert.equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
});
-test("innerHeight()", function() {
- expect( 6 );
+QUnit.test("innerHeight()", function( assert ) {
+ assert.expect( 6 );
var $div, div,
$win = jQuery( window ),
$doc = jQuery( document );
- equal( jQuery( window ).innerHeight(), $win.height(), "Test on window" );
- equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" );
+ assert.equal( jQuery( window ).innerHeight(), $win.height(), "Test on window" );
+ assert.equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" );
$div = jQuery( "#nothiddendiv" );
$div.css({
@@ -185,11 +185,11 @@ test("innerHeight()", function() {
"height": 30
});
- equal( $div.innerHeight(), 30, "Test with margin and border" );
+ assert.equal( $div.innerHeight(), 30, "Test with margin and border" );
$div.css( "padding", "20px" );
- equal( $div.innerHeight(), 70, "Test with margin, border and padding" );
+ assert.equal( $div.innerHeight(), 70, "Test with margin, border and padding" );
$div.hide();
- equal( $div.innerHeight(), 70, "Test hidden div" );
+ assert.equal( $div.innerHeight(), 70, "Test hidden div" );
// reset styles
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
@@ -197,38 +197,38 @@ test("innerHeight()", function() {
div = jQuery( "
" );
// Temporarily require 0 for backwards compat - should be auto
- equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
+ assert.equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
});
-test("outerWidth()", function() {
- expect( 11 );
+QUnit.test("outerWidth()", function( assert ) {
+ assert.expect( 11 );
var $div, div,
$win = jQuery( window ),
$doc = jQuery( document );
- equal( jQuery( window ).outerWidth(), $win.width(), "Test on window without margin option" );
- equal( jQuery( window ).outerWidth( true ), $win.width(), "Test on window with margin option" );
- equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" );
- equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" );
+ assert.equal( jQuery( window ).outerWidth(), $win.width(), "Test on window without margin option" );
+ assert.equal( jQuery( window ).outerWidth( true ), $win.width(), "Test on window with margin option" );
+ assert.equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" );
+ assert.equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" );
$div = jQuery( "#nothiddendiv" );
$div.css( "width", 30 );
- equal( $div.outerWidth(), 30, "Test with only width set" );
+ assert.equal( $div.outerWidth(), 30, "Test with only width set" );
$div.css( "padding", "20px" );
- equal( $div.outerWidth(), 70, "Test with padding" );
+ assert.equal( $div.outerWidth(), 70, "Test with padding" );
$div.css( "border", "2px solid #fff" );
- equal( $div.outerWidth(), 74, "Test with padding and border" );
+ assert.equal( $div.outerWidth(), 74, "Test with padding and border" );
$div.css( "margin", "10px" );
- equal( $div.outerWidth(), 74, "Test with padding, border and margin without margin option" );
+ assert.equal( $div.outerWidth(), 74, "Test with padding, border and margin without margin option" );
$div.css( "position", "absolute" );
- equal( $div.outerWidth( true ), 94, "Test with padding, border and margin with margin option" );
+ assert.equal( $div.outerWidth( true ), 94, "Test with padding, border and margin with margin option" );
$div.hide();
- equal( $div.outerWidth( true ), 94, "Test hidden div with padding, border and margin with margin option" );
+ assert.equal( $div.outerWidth( true ), 94, "Test hidden div with padding, border and margin with margin option" );
// reset styles
$div.css({ "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" });
@@ -236,14 +236,14 @@ test("outerWidth()", function() {
div = jQuery( "
" );
// Temporarily require 0 for backwards compat - should be auto
- equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
+ assert.equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
});
-test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
- expect(16);
+QUnit.test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function( assert ) {
+ assert.expect(16);
// setup html
var $divNormal = jQuery("
").css({ "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
@@ -253,38 +253,38 @@ test("child of a hidden elem (or unconnected node) has accurate inner/outer/Widt
$divNormal.appendTo("body");
// tests that child div of a hidden div works the same as a normal div
- equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
- equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
- equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
- equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
+ assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" );
+ assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" );
+ assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" );
+ assert.equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" );
// Support: IE 10-11, Edge
// Child height is not always decimal
- equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #9441" );
- equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #9441" );
- equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #9441" );
- equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
+ assert.equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #9441" );
+ assert.equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #9441" );
+ assert.equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #9441" );
+ assert.equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #9300" );
// tests that child div of an unconnected div works the same as a normal div
- equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" );
- equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" );
- equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" );
- equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
+ assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" );
+ assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" );
+ assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" );
+ assert.equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" );
// Support: IE 10-11, Edge
// Child height is not always decimal
- equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #9441" );
- equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #9441" );
- equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #9441" );
- equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #9300" );
+ assert.equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #9441" );
+ assert.equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #9441" );
+ assert.equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #9441" );
+ assert.equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #9300" );
// teardown html
$divHiddenParent.remove();
$divNormal.remove();
});
-test("getting dimensions shouldn't modify runtimeStyle see #9233", function() {
- expect( 1 );
+QUnit.test("getting dimensions shouldn't modify runtimeStyle see #9233", function( assert ) {
+ assert.expect( 1 );
var $div = jQuery( "
" ).appendTo( "#qunit-fixture" ),
div = $div.get( 0 ),
@@ -298,16 +298,16 @@ test("getting dimensions shouldn't modify runtimeStyle see #9233", function() {
$div.outerWidth( true );
if ( runtimeStyle ) {
- equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" );
+ assert.equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" );
} else {
- ok( true, "this browser doesn't support runtimeStyle, see #9233" );
+ assert.ok( true, "this browser doesn't support runtimeStyle, see #9233" );
}
$div.remove();
});
-test( "table dimensions", function() {
- expect( 2 );
+QUnit.test( "table dimensions", function( assert ) {
+ assert.expect( 2 );
var table = jQuery("
").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 acc
$divNormal.appendTo("body");
// tests that child div of a hidden div works the same as a normal div
- equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" );
- equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" );
- equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" );
- equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
+ assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" );
+ assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" );
+ assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" );
+ assert.equal( $divChild.outerWidth(true), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" );
// Support: IE 10-11, Edge
// Child height is not always decimal
- equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #10413" );
- equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #10413" );
- equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #10413" );
- equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #10413" );
+ assert.equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #10413" );
+ assert.equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #10413" );
+ assert.equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #10413" );
+ assert.equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #10413" );
// tests that child div of an unconnected div works the same as a normal div
- equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" );
- equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" );
- equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" );
- equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
+ assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" );
+ assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" );
+ assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" );
+ assert.equal( $divUnconnected.outerWidth(true), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" );
// Support: IE 10-11, Edge
// Child height is not always decimal
- equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #10413" );
- equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #10413" );
- equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #10413" );
- equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #10413" );
+ assert.equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #10413" );
+ assert.equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #10413" );
+ assert.equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #10413" );
+ assert.equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #10413" );
// teardown html
$divHiddenParent.remove();
$divNormal.remove();
});
-test("outerHeight()", function() {
- expect( 11 );
+QUnit.test("outerHeight()", function( assert ) {
+ assert.expect( 11 );
var $div, div,
$win = jQuery( window ),
$doc = jQuery( document );
- equal( jQuery( window ).outerHeight(), $win.height(), "Test on window without margin option" );
- equal( jQuery( window ).outerHeight( true ), $win.height(), "Test on window with margin option" );
- equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" );
- equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" );
+ assert.equal( jQuery( window ).outerHeight(), $win.height(), "Test on window without margin option" );
+ assert.equal( jQuery( window ).outerHeight( true ), $win.height(), "Test on window with margin option" );
+ assert.equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" );
+ assert.equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" );
$div = jQuery( "#nothiddendiv" );
$div.css( "height", 30 );
- equal( $div.outerHeight(), 30, "Test with only width set" );
+ assert.equal( $div.outerHeight(), 30, "Test with only width set" );
$div.css( "padding", "20px" );
- equal( $div.outerHeight(), 70, "Test with padding" );
+ assert.equal( $div.outerHeight(), 70, "Test with padding" );
$div.css( "border", "2px solid #fff" );
- equal( $div.outerHeight(), 74, "Test with padding and border" );
+ assert.equal( $div.outerHeight(), 74, "Test with padding and border" );
$div.css( "margin", "10px" );
- equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" );
- equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" );
+ assert.equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" );
+ assert.equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" );
$div.hide();
- equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" );
+ assert.equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" );
// reset styles
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
@@ -392,78 +392,82 @@ test("outerHeight()", function() {
div = jQuery( "
" );
// Temporarily require 0 for backwards compat - should be auto
- equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
+ assert.equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
div.remove();
QUnit.expectJqData( this, $div[ 0 ], "olddisplay" );
});
-test("passing undefined is a setter #5571", function() {
- expect(4);
- equal(jQuery("#nothiddendiv").height(30).height(undefined).height(), 30, ".height(undefined) is chainable (#5571)");
- equal(jQuery("#nothiddendiv").height(30).innerHeight(undefined).height(), 30, ".innerHeight(undefined) is chainable (#5571)");
- equal(jQuery("#nothiddendiv").height(30).outerHeight(undefined).height(), 30, ".outerHeight(undefined) is chainable (#5571)");
- equal(jQuery("#nothiddendiv").width(30).width(undefined).width(), 30, ".width(undefined) is chainable (#5571)");
+QUnit.test("passing undefined is a setter #5571", function( assert ) {
+ assert.expect(4);
+ assert.equal(jQuery("#nothiddendiv").height(30).height(undefined).height(), 30, ".height(undefined) is chainable (#5571)");
+ assert.equal(jQuery("#nothiddendiv").height(30).innerHeight(undefined).height(), 30, ".innerHeight(undefined) is chainable (#5571)");
+ assert.equal(jQuery("#nothiddendiv").height(30).outerHeight(undefined).height(), 30, ".outerHeight(undefined) is chainable (#5571)");
+ assert.equal(jQuery("#nothiddendiv").width(30).width(undefined).width(), 30, ".width(undefined) is chainable (#5571)");
});
-test( "getters on non elements should return null", function() {
- expect( 8 );
+QUnit.test( "getters on non elements should return null", function( assert ) {
+ assert.expect( 8 );
var nonElem = jQuery("notAnElement");
- strictEqual( nonElem.width(), null, ".width() is not null (#12283)" );
- strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" );
- strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" );
- strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" );
+ assert.strictEqual( nonElem.width(), null, ".width() is not null (#12283)" );
+ assert.strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" );
+ assert.strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" );
+ assert.strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" );
- strictEqual( nonElem.height(), null, ".height() is not null (#12283)" );
- strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" );
- strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" );
- strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" );
+ assert.strictEqual( nonElem.height(), null, ".height() is not null (#12283)" );
+ assert.strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" );
+ assert.strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" );
+ assert.strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" );
});
-test("setters with and without box-sizing:border-box", function(){
- expect(20);
+QUnit.test("setters with and without box-sizing:border-box", function( assert ){
+ assert.expect(20);
// Support: Android 2.3 (-webkit-box-sizing).
var el_bb = jQuery("
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/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" );
@@ -475,7 +479,7 @@ test( "allow modification of coordinates argument (gh-1848)", function() {
});
offsetTop = element.offset().top;
- ok( Math.abs(offsetTop - 100) < 0.02,
+ assert.ok( Math.abs(offsetTop - 100) < 0.02,
"coordinates are modified (got offset.top: " + offsetTop + ")");
});
diff --git a/test/unit/effects.js b/test/unit/effects.js
index b5f45bf6d..934b3e193 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();
@@ -27,41 +27,41 @@ 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("
").hide().appendTo("#qunit-fixture").show();
- equal( div.css("display"), "block", "Make sure pre-hidden divs show" );
+ assert.equal( div.css("display"), "block", "Make sure pre-hidden divs show" );
// Clean up the detached node
div.remove();
});
-test("show()", function () {
- expect( 27 );
+QUnit.test("show()", function( assert ) {
+ assert.expect( 27 );
var div, speeds, old, test,
hiddendiv = jQuery("div.hidden");
- equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
+ assert.equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
hiddendiv.css("display", "block");
- equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
+ assert.equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
hiddendiv.show();
- equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
+ assert.equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
hiddendiv.css("display","");
div = jQuery("#fx-queue div").slice(0, 4);
div.show().each(function() {
- notEqual(this.style.display, "none", "don't change any
with display block");
+ assert.notEqual(this.style.display, "none", "don't change any
with display block");
});
speeds = {
@@ -77,7 +77,7 @@ test("show()", function () {
pass = false;
}
});
- ok( pass, "Show with " + name);
+ assert.ok( pass, "Show with " + name);
});
jQuery.each(speeds, function(name, speed) {
@@ -85,7 +85,7 @@ test("show()", function () {
div.hide().show(speed, function() {
pass = false;
});
- ok( pass, "Show with " + name + " does not call animate callback" );
+ assert.ok( pass, "Show with " + name + " does not call animate callback" );
});
// Tolerate data from show()/hide()
@@ -121,7 +121,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 );
});
jQuery("#show-tests").remove();
@@ -131,8 +131,8 @@ test("show()", function () {
jQuery("
test
text
test ").hide().remove();
});
-test("show(Number) - other displays", function() {
- expect(30);
+QUnit.test("show(Number) - other displays", function( assert ) {
+ assert.expect(30);
jQuery(
"
" +
@@ -174,7 +174,7 @@ test("show(Number) - other displays", function() {
this.clock.tick( 50 );
jQuery.each( test, function( selector, expected ) {
jQuery( selector, "#show-tests" ).each(function() {
- equal(
+ assert.equal(
jQuery( this ).css( "display" ),
expected === "inline" ? "inline-block" : expected,
"Correct display type during animation for " + selector
@@ -184,7 +184,7 @@ test("show(Number) - other displays", function() {
this.clock.tick( 50 );
jQuery.each( test, function( selector, expected ) {
jQuery( selector, "#show-tests" ).each(function() {
- equal( jQuery( this ).css( "display" ), expected,
+ assert.equal( jQuery( this ).css( "display" ), expected,
"Correct display type after animation for " + selector );
});
});
@@ -193,8 +193,8 @@ test("show(Number) - other displays", function() {
});
// Supports #7397
-test("Persist correct display value", function() {
- expect(3);
+QUnit.test("Persist correct display value", function( assert ) {
+ assert.expect(3);
jQuery( "
foo
" )
.appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" );
@@ -211,11 +211,11 @@ test("Persist correct display value", function() {
$span.hide();
$span.fadeIn(100, function() {
- equal($span.css("display"), display, "Expecting display: " + display);
+ assert.equal($span.css("display"), display, "Expecting display: " + display);
$span.fadeOut(100, function () {
- equal($span.css("display"), displayNone, "Expecting display: " + displayNone);
+ assert.equal($span.css("display"), displayNone, "Expecting display: " + displayNone);
$span.fadeIn(100, function() {
- equal($span.css("display"), display, "Expecting display: " + display);
+ assert.equal($span.css("display"), display, "Expecting display: " + display);
});
});
});
@@ -225,16 +225,16 @@ test("Persist correct display value", function() {
QUnit.expectJqData( this, $span, "olddisplay" );
});
-test("animate(Hash, Object, Function)", function() {
- expect(1);
+QUnit.test("animate(Hash, Object, Function)", function( assert ) {
+ assert.expect(1);
var hash = {opacity: "show"},
hashCopy = jQuery.extend({}, hash);
jQuery("#foo").animate(hash, 0, function() {
- equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" );
+ assert.equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" );
});
});
-test("animate relative values", function() {
+QUnit.test("animate relative values", function( assert ) {
var value = 40,
clock = this.clock,
@@ -244,7 +244,7 @@ test("animate relative values", function() {
.css({ position: "absolute", height: "50em", width: "50em" }),
animations = bases.length * adjustments.length;
- expect( 2 * animations );
+ assert.expect( 2 * animations );
jQuery.each( bases, function( _, baseUnit ) {
jQuery.each( adjustments, function( _, adjustUnit ) {
@@ -261,9 +261,9 @@ test("animate relative values", function() {
adjustScale = elem[ 0 ].offsetWidth / value;
elem.css( "width", base ).animate( adjust, 100, function() {
- equal( this.offsetHeight, value * baseScale + 2 * adjustScale,
+ assert.equal( this.offsetHeight, value * baseScale + 2 * adjustScale,
baseUnit + "+=" + adjustUnit );
- equal( this.offsetWidth, value * baseScale - 2 * adjustScale,
+ assert.equal( this.offsetWidth, value * baseScale - 2 * adjustScale,
baseUnit + "-=" + adjustUnit );
});
@@ -273,66 +273,66 @@ test("animate relative values", function() {
});
});
-test("animate negative height", function() {
- expect(1);
+QUnit.test("animate negative height", function( assert ) {
+ assert.expect(1);
jQuery("#foo").animate({ height: -100 }, 100, function() {
- equal( this.offsetHeight, 0, "Verify height." );
+ assert.equal( this.offsetHeight, 0, "Verify height." );
});
this.clock.tick( 100 );
});
-test("animate negative margin", function() {
- expect(1);
+QUnit.test("animate negative margin", function( assert ) {
+ assert.expect(1);
jQuery("#foo").animate({ "marginTop": -100 }, 100, function() {
- equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
+ assert.equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
});
this.clock.tick( 100 );
});
-test("animate negative margin with px", function() {
- expect(1);
+QUnit.test("animate negative margin with px", function( assert ) {
+ assert.expect(1);
jQuery("#foo").animate({ marginTop: "-100px" }, 100, function() {
- equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
+ assert.equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
});
this.clock.tick( 100 );
});
-test("animate negative padding", function() {
- expect(1);
+QUnit.test("animate negative padding", function( assert ) {
+ assert.expect(1);
jQuery("#foo").animate({ "paddingBottom": -100 }, 100, function() {
- equal( jQuery(this).css("paddingBottom"), "0px", "Verify paddingBottom." );
+ assert.equal( jQuery(this).css("paddingBottom"), "0px", "Verify paddingBottom." );
});
this.clock.tick( 100 );
});
-test("animate block as inline width/height", function() {
- expect(3);
+QUnit.test("animate block as inline width/height", function( assert ) {
+ assert.expect(3);
jQuery("#foo").css({ display: "inline", width: "", height: "" }).animate({ width: 42, height: 42 }, 100, function() {
- equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
- equal( this.offsetWidth, 42, "width was animated" );
- equal( this.offsetHeight, 42, "height was animated" );
+ assert.equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
+ assert.equal( this.offsetWidth, 42, "width was animated" );
+ assert.equal( this.offsetHeight, 42, "height was animated" );
});
this.clock.tick( 100 );
});
-test("animate native inline width/height", function() {
- expect(3);
+QUnit.test("animate native inline width/height", function( assert ) {
+ assert.expect(3);
jQuery("#foo").css({ display: "", width: "", height: "" })
.append("
text ")
.children("span")
.animate({ width: 42, height: 42 }, 100, function() {
- equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
- equal( this.offsetWidth, 42, "width was animated" );
- equal( this.offsetHeight, 42, "height was animated" );
+ assert.equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
+ assert.equal( this.offsetWidth, 42, "width was animated" );
+ assert.equal( this.offsetHeight, 42, "height was animated" );
});
this.clock.tick( 100 );
});
-test( "animate block width/height", function() {
- expect( 3 );
+QUnit.test( "animate block width/height", function( assert ) {
+ assert.expect( 3 );
jQuery("
").appendTo("#qunit-fixture").css({
display: "block",
@@ -346,46 +346,46 @@ test( "animate block width/height", function() {
duration: 100,
step: function() {
if ( jQuery( this ).width() > 42 ) {
- ok( false, "width was incorrectly augmented during animation" );
+ assert.ok( false, "width was incorrectly augmented during animation" );
}
},
complete: function() {
- equal( jQuery( this ).css("display"), "block", "inline-block was not set on block element when animating width/height" );
- equal( jQuery( this ).width(), 42, "width was animated" );
- equal( jQuery( this ).height(), 42, "height was animated" );
+ assert.equal( jQuery( this ).css("display"), "block", "inline-block was not set on block element when animating width/height" );
+ assert.equal( jQuery( this ).width(), 42, "width was animated" );
+ assert.equal( jQuery( this ).height(), 42, "height was animated" );
}
});
this.clock.tick( 100 );
});
-test("animate table width/height", function() {
- expect(1);
+QUnit.test("animate table width/height", function( assert ) {
+ assert.expect(1);
var displayMode = jQuery("#table").css("display") !== "table" ? "block" : "table";
jQuery("#table").animate({ width: 42, height: 42 }, 100, function() {
- equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
+ assert.equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
});
this.clock.tick( 100 );
});
-test("animate table-row width/height", function() {
- expect(3);
+QUnit.test("animate table-row width/height", function( assert ) {
+ assert.expect(3);
var tr = jQuery( "#table" )
.attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
.html( "
" )
.find( "tr" );
tr.animate({ width: 10, height: 10 }, 100, function() {
- equal( jQuery( this ).css( "display" ), "table-row", "display mode is correct" );
- equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
- equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
+ assert.equal( jQuery( this ).css( "display" ), "table-row", "display mode is correct" );
+ assert.equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
+ assert.equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
});
this.clock.tick( 100 );
});
-test("animate table-cell width/height", function() {
- expect(3);
+QUnit.test("animate table-cell width/height", function( assert ) {
+ assert.expect(3);
var td = jQuery( "#table" )
.attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
@@ -393,42 +393,42 @@ test("animate table-cell width/height", function() {
.find( "td" );
td.animate({ width: 10, height: 10 }, 100, function() {
- equal( jQuery( this ).css( "display" ), "table-cell", "display mode is correct" );
- equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
- equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
+ assert.equal( jQuery( this ).css( "display" ), "table-cell", "display mode is correct" );
+ assert.equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
+ assert.equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
});
this.clock.tick( 100 );
});
-test("animate percentage(%) on width/height", function() {
- expect( 2 );
+QUnit.test("animate percentage(%) on width/height", function( assert ) {
+ assert.expect( 2 );
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 = [];
@@ -436,8 +436,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
@@ -446,8 +446,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({
@@ -456,16 +456,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({
@@ -474,18 +474,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 = [];
@@ -497,28 +497,28 @@ 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"),
@@ -528,94 +528,94 @@ 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
this.clock.tick( 400 );
});
-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"),
@@ -627,17 +627,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");
@@ -646,15 +646,15 @@ 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", "");
});
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" );
@@ -668,23 +668,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,
@@ -696,19 +696,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,
@@ -721,7 +721,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");
@@ -734,8 +734,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 });
@@ -744,8 +744,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");
}
});
@@ -756,7 +756,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
@@ -768,25 +768,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",
@@ -795,13 +795,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"
@@ -813,12 +813,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"
@@ -826,13 +826,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)"
@@ -841,8 +841,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")
@@ -850,8 +850,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 )
@@ -920,7 +920,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" ),
@@ -946,7 +946,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 };
@@ -957,16 +957,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");
@@ -976,33 +976,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" ) {
@@ -1010,9 +1010,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." );
}
}
@@ -1025,19 +1025,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 );
},
@@ -1049,25 +1049,26 @@ 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 );
- this.clock.tick( 400 );
+ 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 );
});
jQuery.makeTest = function( text ){
@@ -1085,21 +1086,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,
@@ -1126,7 +1127,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
@@ -1137,17 +1138,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 );
@@ -1159,9 +1160,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,
@@ -1189,18 +1190,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,
@@ -1223,20 +1224,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;
@@ -1245,33 +1246,33 @@ 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, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
+ assert.ok( !jQuery._data(div, "olddisplay"), "olddisplay 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( 6 );
+QUnit.test( "animate properties missing px w/ opacity as last (#9074)", function( assert ) {
+ assert.expect( 6 );
var ml, l,
div = jQuery( "
" )
@@ -1279,8 +1280,8 @@ test( "animate properties missing px w/ opacity as last (#9074)", function() {
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,
@@ -1291,15 +1292,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;
@@ -1310,14 +1311,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" );
@@ -1335,30 +1336,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({
@@ -1369,24 +1370,24 @@ 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");
$div.css("fill-opacity", 0).animate({ "fill-opacity": 1.0 }, 0, 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,
@@ -1417,9 +1418,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 ) + "%" );
});
@@ -1435,7 +1436,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 ) + "%" );
});
@@ -1449,8 +1450,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 = {
@@ -1467,17 +1468,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({
@@ -1493,7 +1494,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]
@@ -1503,41 +1504,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 env = this,
methods = {
@@ -1557,49 +1558,49 @@ 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" );
QUnit.expectJqData( env, $divNone[ 0 ], "olddisplay" );
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" );
@@ -1608,15 +1609,15 @@ test("Initial step callback should show element as :animated (#14623)", function
}, {
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
");
@@ -1628,17 +1629,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,
@@ -1657,34 +1658,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;
@@ -1695,14 +1696,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++;
}
});
@@ -1710,13 +1711,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({
@@ -1725,19 +1726,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;
@@ -1747,7 +1748,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
@@ -1755,23 +1756,23 @@ 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,
queue: false,
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( "
" ).css({ width: 284, height: 1 }).appendTo( "#qunit-fixture" ),
child = parent.children().css({ fontSize: "98.6in", width: "0.01em", height: 1 }),
@@ -1785,22 +1786,22 @@ test( "animate does not change start value for non-px animation (#7109)", functi
}
}).queue( function( next ) {
var ratio = computed[ 0 ] / actual;
- ok( ratio > 0.9 && ratio < 1.1 , "Starting width was close enough" );
+ assert.ok( ratio > 0.9 && ratio < 1.1 , "Starting width was close enough" );
next();
parent.remove();
});
this.clock.tick( 10 );
});
-test( "non-px animation handles non-numeric start (#11971)", function() {
- expect( 2 );
+QUnit.test( "non-px animation handles non-numeric start (#11971)", function( assert ) {
+ assert.expect( 2 );
var foo = jQuery("#foo"),
initial = foo.css("backgroundPositionX");
if ( !initial ) {
- expect(1);
- ok( true, "Style property not understood" );
+ assert.expect(1);
+ assert.ok( true, "Style property not understood" );
return;
}
@@ -1812,20 +1813,20 @@ test( "non-px animation handles non-numeric start (#11971)", function() {
}
if ( parseFloat( initial ) ) {
- equal( jQuery.style( this, "backgroundPositionX" ), initial, "Numeric start preserved" );
+ assert.equal( jQuery.style( this, "backgroundPositionX" ), initial, "Numeric start preserved" );
} else {
- equal( jQuery.style( this, "backgroundPositionX" ), "0%", "Non-numeric start zeroed" );
+ assert.equal( jQuery.style( this, "backgroundPositionX" ), "0%", "Non-numeric start zeroed" );
}
},
done: function() {
- equal( jQuery.style( this, "backgroundPositionX" ), "42%", "End reached" );
+ assert.equal( jQuery.style( this, "backgroundPositionX" ), "42%", "End reached" );
}
});
this.clock.tick( 10 );
});
-test("Animation callbacks (#11797)", function() {
- expect( 15 );
+QUnit.test("Animation callbacks (#11797)", function( assert ) {
+ assert.expect( 15 );
var targets = jQuery("#foo").children(),
done = false,
@@ -1834,24 +1835,24 @@ test("Animation callbacks (#11797)", function() {
targets.eq( 0 ).animate( {}, {
duration: 1,
start: function() {
- ok( true, "empty: start" );
+ assert.ok( true, "empty: start" );
},
progress: function( anim, percent ) {
- equal( percent, 0, "empty: progress 0" );
+ assert.equal( percent, 0, "empty: progress 0" );
},
done: function() {
- ok( true, "empty: done" );
+ assert.ok( true, "empty: done" );
},
fail: function() {
- ok( false, "empty: fail" );
+ assert.ok( false, "empty: fail" );
},
always: function() {
- ok( true, "empty: always" );
+ assert.ok( true, "empty: always" );
done = true;
}
});
- ok( done, "empty: done immediately" );
+ assert.ok( done, "empty: done immediately" );
done = false;
targets.eq( 1 ).animate({
@@ -1859,56 +1860,56 @@ test("Animation callbacks (#11797)", function() {
}, {
duration: 1,
start: function() {
- ok( true, "stopped: start" );
+ assert.ok( true, "stopped: start" );
},
progress: function( anim, percent ) {
- equal( percent, 0, "stopped: progress 0" );
+ assert.equal( percent, 0, "stopped: progress 0" );
},
done: function() {
- ok( false, "stopped: done" );
+ assert.ok( false, "stopped: done" );
},
fail: function() {
- ok( true, "stopped: fail" );
+ assert.ok( true, "stopped: fail" );
},
always: function() {
- ok( true, "stopped: always" );
+ assert.ok( true, "stopped: always" );
done = true;
}
}).stop();
- ok( done, "stopped: stopped immediately" );
+ assert.ok( done, "stopped: stopped immediately" );
targets.eq( 2 ).animate({
opacity: 0
}, {
duration: 1,
start: function() {
- ok( true, "async: start" );
+ assert.ok( true, "async: start" );
},
progress: function( anim, percent ) {
// occasionally the progress handler is called twice in first frame.... *shrug*
if ( percent === 0 && expectedProgress === 1 ) {
return;
}
- equal( percent, expectedProgress, "async: progress " + expectedProgress );
+ assert.equal( percent, expectedProgress, "async: progress " + expectedProgress );
// once at 0, once at 1
expectedProgress++;
},
done: function() {
- ok( true, "async: done" );
+ assert.ok( true, "async: done" );
},
fail: function() {
- ok( false, "async: fail" );
+ assert.ok( false, "async: fail" );
},
always: function() {
- ok( true, "async: always" );
+ assert.ok( true, "async: always" );
}
});
this.clock.tick( 10 );
});
-test( "Animate properly sets overflow hidden when animating width/height (#12117)", function() {
- expect( 8 );
+QUnit.test( "Animate properly sets overflow hidden when animating width/height (#12117)", function( assert ) {
+ assert.expect( 8 );
jQuery.each( [ "height", "width" ], function( _, prop ) {
jQuery.each( [ 100, 0 ], function( _, value ) {
@@ -1916,26 +1917,26 @@ test( "Animate properly sets overflow hidden when animating width/height (#12117
props = {};
props[ prop ] = value;
div.animate( props, 1 );
- equal( div.css( "overflow" ), "hidden",
+ assert.equal( div.css( "overflow" ), "hidden",
"overflow: hidden set when animating " + prop + " to " + value );
div.stop();
- equal( div.css( "overflow" ), "auto",
+ assert.equal( div.css( "overflow" ), "auto",
"overflow: auto restored after animating " + prop + " to " + value );
});
});
});
-test( "Each tick of the timer loop uses a fresh time (#12837)", function() {
+QUnit.test( "Each tick of the timer loop uses a fresh time (#12837)", function( assert ) {
var lastVal,
tmp = jQuery({
test: 0
});
- expect( 3 );
+ assert.expect( 3 );
tmp.animate({
test: 100
}, {
step: function( p, fx ) {
- ok( fx.now !== lastVal, "Current value is not the last value: " + lastVal + " - " + fx.now );
+ assert.ok( fx.now !== lastVal, "Current value is not the last value: " + lastVal + " - " + fx.now );
lastVal = fx.now;
}
});
@@ -1950,11 +1951,11 @@ test( "Each tick of the timer loop uses a fresh time (#12837)", function() {
tmp.stop();
});
-test( "Animations with 0 duration don't ease (#12273)", function() {
- expect( 1 );
+QUnit.test( "Animations with 0 duration don't ease (#12273)", function( assert ) {
+ assert.expect( 1 );
jQuery.easing.test = function() {
- ok( false, "Called easing" );
+ assert.ok( false, "Called easing" );
};
jQuery( "#foo" ).animate({
@@ -1963,7 +1964,7 @@ test( "Animations with 0 duration don't ease (#12273)", function() {
duration: 0,
easing: "test",
complete: function() {
- equal( jQuery( this ).height(), 100, "Height is 100" );
+ assert.equal( jQuery( this ).height(), 100, "Height is 100" );
}
});
@@ -1974,7 +1975,7 @@ jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
// this test would look a lot better if we were using something to override
// the default timers
var duration = 1500;
- test( "toggle state tests: " + method + " (#8685)", function() {
+ QUnit.test( "toggle state tests: " + method + " (#8685)", function( assert ) {
function secondToggle() {
var stopped = parseFloat( element.css( check ) );
tested = false;
@@ -1983,8 +1984,8 @@ jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
step: function( p, fx ) {
if ( fx.pos > 0.1 && fx.prop === check && !tested ) {
tested = true;
- equal( fx.start, stopped, check + " starts at " + stopped + " where it stopped" );
- equal( fx.end, original, check + " ending value is " + original );
+ assert.equal( fx.start, stopped, check + " starts at " + stopped + " where it stopped" );
+ assert.equal( fx.end, original, check + " ending value is " + original );
element.stop();
}
}
@@ -1996,7 +1997,7 @@ jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
check = method === "slideToggle" ? "height" : "opacity",
element = jQuery("#foo").height( 200 );
- expect( 4 );
+ assert.expect( 4 );
element[ method ]({
duration: duration,
@@ -2005,8 +2006,8 @@ jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
if ( fx.pos > 0.1 && fx.prop === check && !tested ) {
tested = true;
original = fx.start;
- ok( fx.start !== 0, check + " is starting at " + original + " on first toggle (non-zero)" );
- equal( fx.end, 0, check + " is ending at 0 on first toggle" );
+ assert.ok( fx.start !== 0, check + " is starting at " + original + " on first toggle (non-zero)" );
+ assert.equal( fx.end, 0, check + " is ending at 0 on first toggle" );
element.stop();
}
},
@@ -2017,18 +2018,18 @@ jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
});
});
-test( "jQuery.fx.start & jQuery.fx.stop hook points", function() {
+QUnit.test( "jQuery.fx.start & jQuery.fx.stop hook points", function( assert ) {
var oldStart = jQuery.fx.start,
oldStop = jQuery.fx.stop,
foo = jQuery({ foo: 0 });
- expect( 3 );
+ assert.expect( 3 );
jQuery.fx.start = function() {
- ok( true, "start called" );
+ assert.ok( true, "start called" );
};
jQuery.fx.stop = function() {
- ok( true, "stop called" );
+ assert.ok( true, "stop called" );
};
// calls start
@@ -2044,7 +2045,7 @@ test( "jQuery.fx.start & jQuery.fx.stop hook points", function() {
jQuery.fx.stop = oldStop;
});
-test( ".finish() completes all queued animations", function() {
+QUnit.test( ".finish() completes all queued animations", function( assert ) {
var animations = {
top: 100,
left: 100,
@@ -2053,23 +2054,23 @@ test( ".finish() completes all queued animations", function() {
},
div = jQuery("
");
- expect( 11 );
+ assert.expect( 11 );
jQuery.each( animations, function( prop, value ) {
var anim = {};
anim[ prop ] = value;
// the delay shouldn't matter at all!
div.css( prop, 1 ).animate( anim, function() {
- ok( true, "Called animation callback for " + prop );
+ assert.ok( true, "Called animation callback for " + prop );
}).delay( 100 );
});
- equal( div.queue().length, 8, "8 animations in the queue" );
+ assert.equal( div.queue().length, 8, "8 animations in the queue" );
div.finish();
jQuery.each( animations, function( prop, value ) {
- equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
+ assert.equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
});
- equal( div.queue().length, 0, "empty queue when done" );
- equal( div.is(":animated"), false, ":animated doesn't match" );
+ assert.equal( div.queue().length, 0, "empty queue when done" );
+ assert.equal( div.is(":animated"), false, ":animated doesn't match" );
// cleanup
div.remove();
@@ -2077,7 +2078,7 @@ test( ".finish() completes all queued animations", function() {
jQuery.fx.tick();
});
-test( ".finish( false ) - unqueued animations", function() {
+QUnit.test( ".finish( false ) - unqueued animations", function( assert ) {
var animations = {
top: 100,
left: 100,
@@ -2086,7 +2087,7 @@ test( ".finish( false ) - unqueued animations", function() {
},
div = jQuery("
");
- expect( 10 );
+ assert.expect( 10 );
jQuery.each( animations, function( prop, value ) {
var anim = {};
@@ -2094,16 +2095,16 @@ test( ".finish( false ) - unqueued animations", function() {
div.css( prop, 1 ).animate( anim, {
queue: false,
complete: function() {
- ok( true, "Called animation callback for " + prop );
+ assert.ok( true, "Called animation callback for " + prop );
}
});
});
- equal( div.queue().length, 0, "0 animations in the queue" );
+ assert.equal( div.queue().length, 0, "0 animations in the queue" );
div.finish( false );
jQuery.each( animations, function( prop, value ) {
- equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
+ assert.equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
});
- equal( div.is(":animated"), false, ":animated doesn't match" );
+ assert.equal( div.is(":animated"), false, ":animated doesn't match" );
// cleanup
div.remove();
@@ -2111,7 +2112,7 @@ test( ".finish( false ) - unqueued animations", function() {
jQuery.fx.tick();
});
-test( ".finish( \"custom\" ) - custom queue animations", function() {
+QUnit.test( ".finish( \"custom\" ) - custom queue animations", function( assert ) {
var animations = {
top: 100,
left: 100,
@@ -2120,7 +2121,7 @@ test( ".finish( \"custom\" ) - custom queue animations", function() {
},
div = jQuery("
");
- expect( 11 );
+ assert.expect( 11 );
jQuery.each( animations, function( prop, value ) {
var anim = {};
@@ -2128,19 +2129,19 @@ test( ".finish( \"custom\" ) - custom queue animations", function() {
div.css( prop, 1 ).animate( anim, {
queue: "custom",
complete: function() {
- ok( true, "Called animation callback for " + prop );
+ assert.ok( true, "Called animation callback for " + prop );
}
});
});
- equal( div.queue( "custom" ).length, 4, "4 animations in the queue" );
+ assert.equal( div.queue( "custom" ).length, 4, "4 animations in the queue" );
// start the first animation
div.dequeue( "custom" );
- equal( div.is(":animated"), true, ":animated matches" );
+ assert.equal( div.is(":animated"), true, ":animated matches" );
div.finish( "custom" );
jQuery.each( animations, function( prop, value ) {
- equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
+ assert.equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
});
- equal( div.is(":animated"), false, ":animated doesn't match" );
+ assert.equal( div.is(":animated"), false, ":animated doesn't match" );
// cleanup
div.remove();
@@ -2148,51 +2149,51 @@ test( ".finish( \"custom\" ) - custom queue animations", function() {
jQuery.fx.tick();
});
-test( ".finish() calls finish of custom queue functions", function() {
+QUnit.test( ".finish() calls finish of custom queue functions", function( assert ) {
function queueTester( next, hooks ) {
hooks.stop = function( gotoEnd ) {
inside++;
- equal( this, div[0] );
- ok( gotoEnd, "hooks.stop(true) called");
+ assert.equal( this, div[0] );
+ assert.ok( gotoEnd, "hooks.stop(true) called");
};
}
var div = jQuery( "
" ),
inside = 0,
outside = 0;
- expect( 6 );
+ assert.expect( 6 );
queueTester.finish = function() {
outside++;
- ok( true, "Finish called on custom queue function" );
+ assert.ok( true, "Finish called on custom queue function" );
};
div.queue( queueTester ).queue( queueTester ).queue( queueTester ).finish();
- equal( inside, 1, "1 stop(true) callback" );
- equal( outside, 2, "2 finish callbacks" );
+ assert.equal( inside, 1, "1 stop(true) callback" );
+ assert.equal( outside, 2, "2 finish callbacks" );
div.remove();
});
-test( ".finish() is applied correctly when multiple elements were animated (#13937)", function() {
- expect( 3 );
+QUnit.test( ".finish() is applied correctly when multiple elements were animated (#13937)", function( assert ) {
+ assert.expect( 3 );
var elems = jQuery("
0 1 2 ");
elems.animate( { opacity: 0 }, 1500 ).animate( { opacity: 1 }, 1500 );
setTimeout(function() {
elems.eq( 1 ).finish();
- ok( !elems.eq( 1 ).queue().length, "empty queue for .finish()ed element" );
- ok( elems.eq( 0 ).queue().length, "non-empty queue for preceding element" );
- ok( elems.eq( 2 ).queue().length, "non-empty queue for following element" );
+ assert.ok( !elems.eq( 1 ).queue().length, "empty queue for .finish()ed element" );
+ assert.ok( elems.eq( 0 ).queue().length, "non-empty queue for preceding element" );
+ assert.ok( elems.eq( 2 ).queue().length, "non-empty queue for following element" );
elems.stop( true );
}, 100 );
this.clock.tick( 1500 );
});
-test( "slideDown() after stop() (#13483)", function() {
- expect( 2 );
+QUnit.test( "slideDown() after stop() (#13483)", function( assert ) {
+ assert.expect( 2 );
var ul = jQuery( "
" )
.appendTo("#qunit-fixture"),
@@ -2204,7 +2205,7 @@ test( "slideDown() after stop() (#13483)", function() {
clock.tick( 500 );
ul.stop( true );
ul.slideDown( 1, function() {
- equal( ul.height(), origHeight, "slideDown() after interrupting slideUp() with stop(). Height must be in original value" );
+ assert.equal( ul.height(), origHeight, "slideDown() after interrupting slideUp() with stop(). Height must be in original value" );
// Second test. slideDown() -> stop() in the middle -> slideDown() until the end
ul.slideUp( 1 );
@@ -2213,7 +2214,7 @@ test( "slideDown() after stop() (#13483)", function() {
clock.tick( 500 );
ul.stop( true );
ul.slideDown( 1 );
- equal( ul.height(), origHeight, "slideDown() after interrupting slideDown() with stop(). Height must be in original value" );
+ assert.equal( ul.height(), origHeight, "slideDown() after interrupting slideDown() with stop(). Height must be in original value" );
// Cleanup
ul.remove();
@@ -2224,8 +2225,8 @@ test( "slideDown() after stop() (#13483)", function() {
clock.tick( 10 );
});
-test( "Respect display value on inline elements (#14824)", function() {
- expect( 2 );
+QUnit.test( "Respect display value on inline elements (#14824)", function( assert ) {
+ assert.expect( 2 );
var clock = this.clock,
fromStyleSheet = jQuery( "
" ),
@@ -2235,14 +2236,14 @@ test( "Respect display value on inline elements (#14824)", function() {
fromStyleSheet.slideUp(function() {
jQuery( this ).slideDown( function() {
- equal( jQuery( this ).css( "display" ), "block",
+ assert.equal( jQuery( this ).css( "display" ), "block",
"Respect previous display value (from stylesheet) on span element" );
});
});
fromStyleAttr.slideUp( function() {
jQuery( this ).slideDown( function() {
- equal( jQuery( this ).css( "display" ), "block",
+ assert.equal( jQuery( this ).css( "display" ), "block",
"Respect previous display value (from style attribute) on span element" );
});
});
@@ -2250,14 +2251,14 @@ test( "Respect display value on inline elements (#14824)", function() {
clock.tick( 800 );
});
-test( "jQuery.easing._default (gh-2218)", function() {
- expect( 2 );
+QUnit.test( "jQuery.easing._default (gh-2218)", function( assert ) {
+ assert.expect( 2 );
jQuery( "#foo" )
.animate( { width: "5px" }, {
duration: 5,
start: function( anim ) {
- equal( anim.opts.easing, jQuery.easing._default,
+ assert.equal( anim.opts.easing, jQuery.easing._default,
"anim.opts.easing should be equal to jQuery.easing._default when the easing argument is not given" );
}
})
@@ -2265,7 +2266,7 @@ test( "jQuery.easing._default (gh-2218)", function() {
duration: 5,
easing: "linear",
start: function( anim ) {
- equal( anim.opts.easing, "linear",
+ assert.equal( anim.opts.easing, "linear",
"anim.opts.easing should be equal to the easing argument" );
}
})
@@ -2274,8 +2275,8 @@ test( "jQuery.easing._default (gh-2218)", function() {
this.clock.tick( 25 );
});
-test( "jQuery.easing._default in Animation (gh-2218", function() {
- expect( 3 );
+QUnit.test( "jQuery.easing._default in Animation (gh-2218", function( assert ) {
+ assert.expect( 3 );
var animation,
defaultEasing = jQuery.easing._default,
@@ -2291,9 +2292,9 @@ test( "jQuery.easing._default in Animation (gh-2218", function() {
animation = jQuery.Animation( testObject, testDest, { "duration": 1 } );
animation.done( function() {
- equal( testObject.width, testDest.width, "Animated width" );
- ok( called, "Custom jQuery.easing._default called" );
- strictEqual( animation.opts.easing, "custom",
+ assert.equal( testObject.width, testDest.width, "Animated width" );
+ assert.ok( called, "Custom jQuery.easing._default called" );
+ assert.strictEqual( animation.opts.easing, "custom",
"Animation used custom jQuery.easing._default" );
jQuery.easing._default = defaultEasing;
delete jQuery.easing.custom;
@@ -2302,8 +2303,8 @@ test( "jQuery.easing._default in Animation (gh-2218", function() {
this.clock.tick( 10 );
});
-test( "jQuery.easing._default in Tween (gh-2218)", function() {
- expect( 3 );
+QUnit.test( "jQuery.easing._default in Tween (gh-2218)", function( assert ) {
+ assert.expect( 3 );
var tween,
defaultEasing = jQuery.easing._default,
@@ -2318,35 +2319,35 @@ test( "jQuery.easing._default in Tween (gh-2218)", function() {
tween = jQuery.Tween( testObject, { "duration": 1 }, "width", 200 );
tween.run( 1 );
- equal( testObject.width, 200, "Animated width" );
- ok( called, "Custom jQuery.easing._default called" );
- strictEqual( tween.easing, "custom",
+ assert.equal( testObject.width, 200, "Animated width" );
+ assert.ok( called, "Custom jQuery.easing._default called" );
+ assert.strictEqual( tween.easing, "custom",
"Animation used custom jQuery.easing._default" );
jQuery.easing._default = defaultEasing;
delete jQuery.easing.custom;
});
-test( "Display value is correct for disconnected nodes (trac-13310)", function() {
- expect( 3 );
+QUnit.test( "Display value is correct for disconnected nodes (trac-13310)", function( assert ) {
+ assert.expect( 3 );
var div = jQuery("
");
- equal( div.css( "display", "inline" ).hide().show().appendTo("body").css( "display" ), "inline", "Initialized display value has returned" );
+ assert.equal( div.css( "display", "inline" ).hide().show().appendTo("body").css( "display" ), "inline", "Initialized display value has returned" );
div.remove();
div.css( "display", "none" ).hide();
- equal( jQuery._data( div[ 0 ], "olddisplay" ), undefined, "olddisplay is undefined after hiding a detached and hidden element" );
+ assert.equal( jQuery._data( div[ 0 ], "olddisplay" ), undefined, "olddisplay is undefined after hiding a detached and hidden element" );
div.remove();
div.css( "display", "inline-block" ).hide().appendTo("body").fadeIn(function() {
- equal( div.css( "display" ), "inline-block", "Initialized display value has returned" );
+ assert.equal( div.css( "display" ), "inline-block", "Initialized display value has returned" );
div.remove();
});
this.clock.tick( 1000 );
});
-test( "Show/hide/toggle and display: inline", function() {
- expect( 40 );
+QUnit.test( "Show/hide/toggle and display: inline", function( assert ) {
+ assert.expect( 40 );
var clock = this.clock;
@@ -2380,7 +2381,7 @@ test( "Show/hide/toggle and display: inline", function() {
jQuery( completed ).each(function() {
var $el = jQuery( this ),
call = $el.data( "call" );
- strictEqual( $el.css( "display" ), "inline-block", kind + " display during " + call );
+ assert.strictEqual( $el.css( "display" ), "inline-block", kind + " display during " + call );
});
// Interrupted elements should remain inline-block
@@ -2389,7 +2390,7 @@ test( "Show/hide/toggle and display: inline", function() {
jQuery( interrupted ).each(function() {
var $el = jQuery( this ),
call = $el.data( "call" );
- strictEqual( $el.css( "display" ), "inline-block", kind + " display after " + call );
+ assert.strictEqual( $el.css( "display" ), "inline-block", kind + " display after " + call );
});
// Completed elements should not remain inline-block
@@ -2398,7 +2399,7 @@ test( "Show/hide/toggle and display: inline", function() {
var $el = jQuery( this ),
call = $el.data( "call" ),
display = $el.data( "done" );
- strictEqual( $el.css( "display" ), display, kind + " display after " + call );
+ assert.strictEqual( $el.css( "display" ), display, kind + " display after " + call );
});
// A post-animation toggle should not make any element inline-block
@@ -2408,7 +2409,7 @@ test( "Show/hide/toggle and display: inline", function() {
completed.each(function() {
var $el = jQuery( this ),
call = $el.data( "call" );
- ok( $el.css( "display" ) !== "inline-block",
+ assert.ok( $el.css( "display" ) !== "inline-block",
kind + " display is not inline-block after " + call + "+toggle" );
});
});
diff --git a/test/unit/event.js b/test/unit/event.js
index c53690abb..8b0976721 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -1,16 +1,16 @@
-module( "event", {
+QUnit.module( "event", {
setup: function() {
document.body.focus();
},
teardown: moduleTeardown
});
-test("on() with non-null,defined data", function() {
+QUnit.test("on() with non-null,defined data", function( assert ) {
- expect(2);
+ assert.expect(2);
var handler = function( event, data ) {
- equal( data, 0, "non-null, defined data (zero) is correctly passed" );
+ assert.equal( data, 0, "non-null, defined data (zero) is correctly passed" );
};
jQuery("#foo").on("foo.on", handler);
@@ -23,8 +23,8 @@ test("on() with non-null,defined data", function() {
});
-test("Handler changes and .trigger() order", function() {
- expect(1);
+QUnit.test("Handler changes and .trigger() order", function( assert ) {
+ assert.expect(1);
var markup = jQuery(
"
"
@@ -44,54 +44,54 @@ test("Handler changes and .trigger() order", function() {
markup.find( "b" ).trigger( "click" );
- equal( path, "b p div div ", "Delivered all events" );
+ assert.equal( path, "b p div div ", "Delivered all events" );
markup.remove();
});
-test("on(), with data", function() {
- expect(4);
+QUnit.test("on(), with data", function( assert ) {
+ assert.expect(4);
var test, handler, handler2;
handler = function(event) {
- ok( event.data, "on() with data, check passed data exists" );
- equal( event.data["foo"], "bar", "on() with data, Check value of passed data" );
+ assert.ok( event.data, "on() with data, check passed data exists" );
+ assert.equal( event.data["foo"], "bar", "on() with data, Check value of passed data" );
};
jQuery("#firstp").on("click", {"foo": "bar"}, handler).trigger("click").off("click", handler);
- ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
+ assert.ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
test = function(){};
handler2 = function(event) {
- equal( event.data, test, "on() with function data, Check value of passed data" );
+ assert.equal( event.data, test, "on() with function data, Check value of passed data" );
};
jQuery("#firstp").on("click", test, handler2).trigger("click").off("click", handler2);
});
-test("click(), with data", function() {
- expect(3);
+QUnit.test("click(), with data", function( assert ) {
+ assert.expect(3);
var handler = function(event) {
- ok( event.data, "on() with data, check passed data exists" );
- equal( event.data["foo"], "bar", "on() with data, Check value of passed data" );
+ assert.ok( event.data, "on() with data, check passed data exists" );
+ assert.equal( event.data["foo"], "bar", "on() with data, Check value of passed data" );
};
jQuery("#firstp").on( "click", {"foo": "bar"}, handler).trigger("click").off("click", handler);
- ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
+ assert.ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using data." );
});
-test("on(), with data, trigger with data", function() {
- expect(4);
+QUnit.test("on(), with data, trigger with data", function( assert ) {
+ assert.expect(4);
var handler = function(event, data) {
- ok( event.data, "check passed data exists" );
- equal( event.data.foo, "bar", "Check value of passed data" );
- ok( data, "Check trigger data" );
- equal( data.bar, "foo", "Check value of trigger data" );
+ assert.ok( event.data, "check passed data exists" );
+ assert.equal( event.data.foo, "bar", "Check value of passed data" );
+ assert.ok( data, "Check trigger data" );
+ assert.equal( data.bar, "foo", "Check value of trigger data" );
};
jQuery("#firstp").on("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]).off("click", handler);
});
-test("on(), multiple events at once", function() {
- expect(2);
+QUnit.test("on(), multiple events at once", function( assert ) {
+ assert.expect(2);
var handler,
clickCounter = 0,
mouseoverCounter = 0;
@@ -105,12 +105,12 @@ test("on(), multiple events at once", function() {
};
jQuery("#firstp").on("click mouseover", handler).trigger("click").trigger("mouseover");
- equal( clickCounter, 1, "on() with multiple events at once" );
- equal( mouseoverCounter, 1, "on() with multiple events at once" );
+ assert.equal( clickCounter, 1, "on() with multiple events at once" );
+ assert.equal( mouseoverCounter, 1, "on() with multiple events at once" );
});
-test("on(), five events at once", function() {
- expect(1);
+QUnit.test("on(), five events at once", function( assert ) {
+ assert.expect(1);
var count = 0,
handler = function() {
@@ -122,17 +122,17 @@ test("on(), five events at once", function() {
.trigger("foo").trigger("bar")
.trigger("baz");
- equal( count, 5, "on() five events at once" );
+ assert.equal( count, 5, "on() five events at once" );
});
-test("on(), multiple events at once and namespaces", function() {
- expect(7);
+QUnit.test("on(), multiple events at once and namespaces", function( assert ) {
+ assert.expect(7);
var cur, div,
obj = {};
div = jQuery("
").on("focusin.a", function(e) {
- equal( e.type, cur, "Verify right single event was fired." );
+ assert.equal( e.type, cur, "Verify right single event was fired." );
});
cur = "focusin";
@@ -142,8 +142,8 @@ test("on(), multiple events at once and namespaces", function() {
div.remove();
div = jQuery("
").on("click mouseover", obj, function(e) {
- equal( e.type, cur, "Verify right multi event was fired." );
- equal( e.data, obj, "Make sure the data came in correctly." );
+ assert.equal( e.type, cur, "Verify right multi event was fired." );
+ assert.equal( e.data, obj, "Make sure the data came in correctly." );
});
cur = "click";
@@ -156,7 +156,7 @@ test("on(), multiple events at once and namespaces", function() {
div.remove();
div = jQuery("
").on("focusin.a focusout.b", function(e) {
- equal( e.type, cur, "Verify right multi event was fired." );
+ assert.equal( e.type, cur, "Verify right multi event was fired." );
});
cur = "focusin";
@@ -169,24 +169,24 @@ test("on(), multiple events at once and namespaces", function() {
div.remove();
});
-test("on(), namespace with special add", function() {
- expect(27);
+QUnit.test("on(), namespace with special add", function( assert ) {
+ assert.expect(27);
var i = 0,
div = jQuery("
").appendTo("#qunit-fixture").on( "test", function() {
- ok( true, "Test event fired." );
+ assert.ok( true, "Test event fired." );
});
jQuery.event.special["test"] = {
_default: function( e, data ) {
- equal( e.type, "test", "Make sure we're dealing with a test event." );
- ok( data, "And that trigger data was passed." );
- strictEqual( e.target, div[0], "And that the target is correct." );
- equal( this, window, "And that the context is correct." );
+ assert.equal( e.type, "test", "Make sure we're dealing with a test event." );
+ assert.ok( data, "And that trigger data was passed." );
+ assert.strictEqual( e.target, div[0], "And that the target is correct." );
+ assert.equal( this, window, "And that the context is correct." );
},
setup: function() {},
teardown: function() {
- ok( true, "Teardown called." );
+ assert.ok( true, "Teardown called." );
},
add: function( handleObj ) {
var handler = handleObj.handler;
@@ -196,18 +196,18 @@ test("on(), namespace with special add", function() {
};
},
remove: function() {
- ok( true, "Remove called." );
+ assert.ok( true, "Remove called." );
}
};
div.on( "test.a", { x: 1 }, function( e ) {
- ok( !!e.xyz, "Make sure that the data is getting passed through." );
- equal( e.data["x"], 1, "Make sure data is attached properly." );
+ assert.ok( !!e.xyz, "Make sure that the data is getting passed through." );
+ assert.equal( e.data["x"], 1, "Make sure data is attached properly." );
});
div.on( "test.b", { x: 2 }, function( e ) {
- ok( !!e.xyz, "Make sure that the data is getting passed through." );
- equal( e.data["x"], 2, "Make sure data is attached properly." );
+ assert.ok( !!e.xyz, "Make sure that the data is getting passed through." );
+ assert.equal( e.data["x"], 2, "Make sure data is attached properly." );
});
// Should trigger 5
@@ -223,7 +223,7 @@ test("on(), namespace with special add", function() {
div.off("test");
div = jQuery("
").on( "test", function() {
- ok( true, "Test event fired." );
+ assert.ok( true, "Test event fired." );
});
// Should trigger 2
@@ -232,16 +232,16 @@ test("on(), namespace with special add", function() {
delete jQuery.event.special["test"];
});
-test("on(), no data", function() {
- expect(1);
+QUnit.test("on(), no data", function( assert ) {
+ assert.expect(1);
var handler = function(event) {
ok ( !event.data, "Check that no data is added to the event object" );
};
jQuery("#firstp").on("click", handler).trigger("click");
});
-test("on/one/off(Object)", function(){
- expect(6);
+QUnit.test("on/one/off(Object)", function( assert ){
+ assert.expect(6);
var $elem,
clickCounter = 0,
@@ -281,12 +281,12 @@ test("on/one/off(Object)", function(){
trigger();
- equal( clickCounter, 3, "on(Object)" );
- equal( mouseoverCounter, 3, "on(Object)" );
+ assert.equal( clickCounter, 3, "on(Object)" );
+ assert.equal( mouseoverCounter, 3, "on(Object)" );
trigger();
- equal( clickCounter, 4, "on(Object)" );
- equal( mouseoverCounter, 4, "on(Object)" );
+ assert.equal( clickCounter, 4, "on(Object)" );
+ assert.equal( mouseoverCounter, 4, "on(Object)" );
jQuery("#firstp").off({
"click":handler,
@@ -294,12 +294,12 @@ test("on/one/off(Object)", function(){
});
trigger();
- equal( clickCounter, 4, "on(Object)" );
- equal( mouseoverCounter, 4, "on(Object)" );
+ assert.equal( clickCounter, 4, "on(Object)" );
+ assert.equal( mouseoverCounter, 4, "on(Object)" );
});
-test("on/off(Object), on/off(Object, String)", function() {
- expect(6);
+QUnit.test("on/off(Object), on/off(Object, String)", function( assert ) {
+ assert.expect(6);
var events,
clickCounter = 0,
@@ -324,24 +324,24 @@ test("on/off(Object), on/off(Object, String)", function() {
$p.on( events, "a", 2 );
trigger();
- equal( clickCounter, 3, "on" );
- equal( mouseoverCounter, 3, "on" );
+ assert.equal( clickCounter, 3, "on" );
+ assert.equal( mouseoverCounter, 3, "on" );
$p.off( events, "a" );
trigger();
- equal( clickCounter, 4, "off" );
- equal( mouseoverCounter, 4, "off" );
+ assert.equal( clickCounter, 4, "off" );
+ assert.equal( mouseoverCounter, 4, "off" );
jQuery( document ).off( events, "#firstp a" );
trigger();
- equal( clickCounter, 4, "off" );
- equal( mouseoverCounter, 4, "off" );
+ assert.equal( clickCounter, 4, "off" );
+ assert.equal( mouseoverCounter, 4, "off" );
});
-test("on immediate propagation", function() {
- expect(2);
+QUnit.test("on immediate propagation", function( assert ) {
+ assert.expect(2);
var lastClick,
$p = jQuery("#firstp"),
@@ -356,7 +356,7 @@ test("on immediate propagation", function() {
lastClick = "click2";
});
$a.trigger( "click" );
- equal( lastClick, "click1", "on stopImmediatePropagation" );
+ assert.equal( lastClick, "click1", "on stopImmediatePropagation" );
jQuery( document ).off( "click", "#firstp a" );
lastClick = "";
@@ -368,17 +368,17 @@ test("on immediate propagation", function() {
lastClick = "click2";
});
$a.trigger( "click" );
- equal( lastClick, "click1", "on stopImmediatePropagation" );
+ assert.equal( lastClick, "click1", "on stopImmediatePropagation" );
$p.off( "click", "**" );
});
-test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
- expect( 3 );
+QUnit.test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function( assert ) {
+ assert.expect( 3 );
var $anchor2 = jQuery( "#anchor2" ),
$main = jQuery( "#qunit-fixture" ),
neverCallMe = function() {
- ok( false, "immediate propagation should have been stopped" );
+ assert.ok( false, "immediate propagation should have been stopped" );
},
fakeClick = function($jq) {
// Use a native click so we don't get jQuery simulated bubbling
@@ -390,7 +390,7 @@ test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
e.preventDefault();
});
$main.on( "click", "#foo", function( e ) {
- equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" );
+ assert.equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" );
});
fakeClick( $anchor2 );
$anchor2.off( "click" );
@@ -399,7 +399,7 @@ test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
// Let the default action occur
});
$main.on("click", "#foo", function(e) {
- equal( e.isDefaultPrevented(), false, "isDefaultPrevented false passed to bubbled event" );
+ assert.equal( e.isDefaultPrevented(), false, "isDefaultPrevented false passed to bubbled event" );
});
fakeClick( $anchor2 );
$anchor2.off( "click" );
@@ -409,11 +409,11 @@ test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
// in such a case.
// Support: Android 2.3
if ( /android 2\.3/i.test( navigator.userAgent ) ) {
- ok( true, "Android 2.3, skipping native stopImmediatePropagation check" );
+ assert.ok( true, "Android 2.3, skipping native stopImmediatePropagation check" );
} else {
$anchor2.on( "click", function( e ) {
e.stopImmediatePropagation();
- ok( true, "anchor was clicked and prop stopped" );
+ assert.ok( true, "anchor was clicked and prop stopped" );
});
$anchor2[0].addEventListener( "click", neverCallMe, false );
fakeClick( $anchor2 );
@@ -421,49 +421,49 @@ test("on bubbling, isDefaultPrevented, stopImmediatePropagation", function() {
}
});
-test("on(), iframes", function() {
- expect( 1 );
+QUnit.test("on(), iframes", function( assert ) {
+ assert.expect( 1 );
// events don't work with iframes, see #939 - this test fails in IE because of contentDocument
var doc = jQuery("#loadediframe").contents();
jQuery("div", doc).on("click", function() {
- ok( true, "Binding to element inside iframe" );
+ assert.ok( true, "Binding to element inside iframe" );
}).trigger("click").off("click");
});
-test("on(), trigger change on select", function() {
- expect(5);
+QUnit.test("on(), trigger change on select", function( assert ) {
+ assert.expect(5);
var counter = 0;
function selectOnChange(event) {
- equal( event.data, counter++, "Event.data is not a global event object" );
+ assert.equal( event.data, counter++, "Event.data is not a global event object" );
}
jQuery("#form select").each(function(i){
jQuery(this).on("change", i, selectOnChange);
}).trigger("change");
});
-test("on(), namespaced events, cloned events", function() {
- expect( 18 );
+QUnit.test("on(), namespaced events, cloned events", function( assert ) {
+ assert.expect( 18 );
var firstp = jQuery( "#firstp" );
firstp.on("custom.test",function(){
- ok(false, "Custom event triggered");
+ assert.ok(false, "Custom event triggered");
});
firstp.on("click",function(e){
- ok(true, "Normal click triggered");
- equal( e.type + e.namespace, "click", "Check that only click events trigger this fn" );
+ assert.ok(true, "Normal click triggered");
+ assert.equal( e.type + e.namespace, "click", "Check that only click events trigger this fn" );
});
firstp.on("click.test",function(e){
var check = "click";
- ok( true, "Namespaced click triggered" );
+ assert.ok( true, "Namespaced click triggered" );
if ( e.namespace ) {
check += "test";
}
- equal( e.type + e.namespace, check, "Check that only click/click.test events trigger this fn" );
+ assert.equal( e.type + e.namespace, check, "Check that only click/click.test events trigger this fn" );
});
//clone(true) element to verify events are cloned correctly
@@ -489,16 +489,16 @@ test("on(), namespaced events, cloned events", function() {
// using contents will get comments regular, text, and comment nodes
jQuery("#nonnodes").contents().on("tester", function () {
- equal(this.nodeType, 1, "Check node,textnode,comment on just does real nodes" );
+ assert.equal(this.nodeType, 1, "Check node,textnode,comment on just does real nodes" );
}).trigger("tester");
// Make sure events stick with appendTo'd elements (which are cloned) #2027
jQuery("
test ").on( "click", function(){ return false; }).appendTo("#qunit-fixture");
- ok( jQuery("a.test").eq(0).triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
+ assert.ok( jQuery("a.test").eq(0).triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
});
-test("on(), multi-namespaced events", function() {
- expect(6);
+QUnit.test("on(), multi-namespaced events", function( assert ) {
+ assert.expect(6);
var order = [
"click.test.abc",
@@ -510,7 +510,7 @@ test("on(), multi-namespaced events", function() {
];
function check(name, msg){
- deepEqual( name, order.shift(), msg );
+ assert.deepEqual( name, order.shift(), msg );
}
jQuery("#firstp").on("custom.test",function() {
@@ -555,15 +555,15 @@ test("on(), multi-namespaced events", function() {
jQuery("#firstp").trigger("custom");
});
-test("namespace-only event binding is a no-op", function(){
- expect(2);
+QUnit.test("namespace-only event binding is a no-op", function( assert ){
+ assert.expect(2);
jQuery("#firstp")
.on( ".whoops", function() {
- ok( false, "called a namespace-only event" );
+ assert.ok( false, "called a namespace-only event" );
})
.on( "whoops", function() {
- ok( true, "called whoops" );
+ assert.ok( true, "called whoops" );
})
.trigger("whoops") // 1
.off(".whoops")
@@ -571,19 +571,19 @@ test("namespace-only event binding is a no-op", function(){
.off("whoops");
});
-test("Empty namespace is ignored", function(){
- expect( 1 );
+QUnit.test("Empty namespace is ignored", function( assert ){
+ assert.expect( 1 );
jQuery("#firstp")
.on( "meow.", function( e ) {
- equal( e.namespace, "", "triggered a namespace-less meow event" );
+ assert.equal( e.namespace, "", "triggered a namespace-less meow event" );
})
.trigger("meow.")
.off("meow.");
});
-test("on(), with same function", function() {
- expect(2);
+QUnit.test("on(), with same function", function( assert ) {
+ assert.expect(2);
var count = 0, func = function(){
count++;
@@ -592,16 +592,16 @@ test("on(), with same function", function() {
jQuery("#liveHandlerOrder").on("foo.bar", func).on("foo.zar", func);
jQuery("#liveHandlerOrder").trigger("foo.bar");
- equal(count, 1, "Verify binding function with multiple namespaces." );
+ assert.equal(count, 1, "Verify binding function with multiple namespaces." );
jQuery("#liveHandlerOrder").off("foo.bar", func).off("foo.zar", func);
jQuery("#liveHandlerOrder").trigger("foo.bar");
- equal(count, 1, "Verify that removing events still work." );
+ assert.equal(count, 1, "Verify that removing events still work." );
});
-test("on(), make sure order is maintained", function() {
- expect(1);
+QUnit.test("on(), make sure order is maintained", function( assert ) {
+ assert.expect(1);
var elem = jQuery("#firstp"), log = [], check = [];
@@ -616,75 +616,75 @@ test("on(), make sure order is maintained", function() {
elem.trigger("click");
- equal( log.join(","), check.join(","), "Make sure order was maintained." );
+ assert.equal( log.join(","), check.join(","), "Make sure order was maintained." );
elem.off("click");
});
-test("on(), with different this object", function() {
- expect(4);
+QUnit.test("on(), with different this object", function( assert ) {
+ assert.expect(4);
var thisObject = { myThis: true },
data = { myData: true },
handler1 = function() {
- equal( this, thisObject, "on() with different this object" );
+ assert.equal( this, thisObject, "on() with different this object" );
},
handler2 = function( event ) {
- equal( this, thisObject, "on() with different this object and data" );
- equal( event.data, data, "on() with different this object and data" );
+ assert.equal( this, thisObject, "on() with different this object and data" );
+ assert.equal( event.data, data, "on() with different this object and data" );
};
jQuery("#firstp")
.on("click", jQuery.proxy(handler1, thisObject)).trigger("click").off("click", handler1)
.on("click", data, jQuery.proxy(handler2, thisObject)).trigger("click").off("click", handler2);
- ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using different this object and data." );
+ assert.ok( !jQuery._data(jQuery("#firstp")[0], "events"), "Event handler unbound when using different this object and data." );
});
-test("on(name, false), off(name, false)", function() {
- expect(3);
+QUnit.test("on(name, false), off(name, false)", function( assert ) {
+ assert.expect(3);
var main = 0;
jQuery("#qunit-fixture").on("click", function(){ main++; });
jQuery("#ap").trigger("click");
- equal( main, 1, "Verify that the trigger happened correctly." );
+ assert.equal( main, 1, "Verify that the trigger happened correctly." );
main = 0;
jQuery("#ap").on("click", false);
jQuery("#ap").trigger("click");
- equal( main, 0, "Verify that no bubble happened." );
+ assert.equal( main, 0, "Verify that no bubble happened." );
main = 0;
jQuery("#ap").off("click", false);
jQuery("#ap").trigger("click");
- equal( main, 1, "Verify that the trigger happened correctly." );
+ assert.equal( main, 1, "Verify that the trigger happened correctly." );
// manually clean up events from elements outside the fixture
jQuery("#qunit-fixture").off("click");
});
-test("on(name, selector, false), off(name, selector, false)", function() {
- expect(3);
+QUnit.test("on(name, selector, false), off(name, selector, false)", function( assert ) {
+ assert.expect(3);
var main = 0;
jQuery("#qunit-fixture").on("click", "#ap", function(){ main++; });
jQuery("#ap").trigger("click");
- equal( main, 1, "Verify that the trigger happened correctly." );
+ assert.equal( main, 1, "Verify that the trigger happened correctly." );
main = 0;
jQuery("#ap").on("click", "#groups", false);
jQuery("#groups").trigger("click");
- equal( main, 0, "Verify that no bubble happened." );
+ assert.equal( main, 0, "Verify that no bubble happened." );
main = 0;
jQuery("#ap").off("click", "#groups", false);
jQuery("#groups").trigger("click");
- equal( main, 1, "Verify that the trigger happened correctly." );
+ assert.equal( main, 1, "Verify that the trigger happened correctly." );
jQuery("#qunit-fixture").off("click", "#ap");
});
-test("on()/trigger()/off() on plain object", function() {
- expect( 7 );
+QUnit.test("on()/trigger()/off() on plain object", function( assert ) {
+ assert.expect( 7 );
var events,
obj = {};
@@ -697,18 +697,18 @@ test("on()/trigger()/off() on plain object", function() {
jQuery(obj).on({
"test": function() {
- ok( true, "Custom event run." );
+ assert.ok( true, "Custom event run." );
},
"submit": function() {
- ok( true, "Custom submit event run." );
+ assert.ok( true, "Custom submit event run." );
}
});
events = jQuery._data(obj, "events");
- ok( events, "Object has events bound." );
- equal( obj["events"], undefined, "Events object on plain objects is not events" );
- equal( obj["test"], undefined, "Make sure that test event is not on the plain object." );
- equal( obj["handle"], undefined, "Make sure that the event handler is not on the plain object." );
+ assert.ok( events, "Object has events bound." );
+ assert.equal( obj["events"], undefined, "Events object on plain objects is not events" );
+ assert.equal( obj["test"], undefined, "Make sure that test event is not on the plain object." );
+ assert.equal( obj["handle"], undefined, "Make sure that the event handler is not on the plain object." );
// Should trigger 1
jQuery(obj).trigger("test");
@@ -723,19 +723,19 @@ test("on()/trigger()/off() on plain object", function() {
// Make sure it doesn't complain when no events are found
jQuery(obj).off("test");
- equal( obj && obj[ jQuery.expando ] &&
+ assert.equal( obj && obj[ jQuery.expando ] &&
obj[ jQuery.expando ][ jQuery.expando ] &&
obj[ jQuery.expando ][ jQuery.expando ]["events"], undefined, "Make sure events object is removed" );
});
-test("off(type)", function() {
- expect( 1 );
+QUnit.test("off(type)", function( assert ) {
+ assert.expect( 1 );
var message, func,
$elem = jQuery("#firstp");
function error(){
- ok( false, message );
+ assert.ok( false, message );
}
message = "unbind passing function";
@@ -764,7 +764,7 @@ test("off(type)", function() {
// Should only unbind the specified function
jQuery( document ).on( "click", function(){
- ok( true, "called handler after selective removal");
+ assert.ok( true, "called handler after selective removal");
});
func = function() {};
jQuery( document )
@@ -774,16 +774,16 @@ test("off(type)", function() {
.off( "click" );
});
-test("off(eventObject)", function() {
- expect(4);
+QUnit.test("off(eventObject)", function( assert ) {
+ assert.expect(4);
var $elem = jQuery("#firstp"),
num;
- function assert( expected ){
+ function check( expected ){
num = 0;
$elem.trigger("foo").triggerHandler("bar");
- equal( num, expected, "Check the right handlers are triggered" );
+ assert.equal( num, expected, "Check the right handlers are triggered" );
}
$elem
@@ -800,19 +800,19 @@ test("off(eventObject)", function() {
num += 4;
});
- assert( 7 );
- assert( 5 );
+ check( 7 );
+ check( 5 );
$elem.off("bar");
- assert( 1 );
+ check( 1 );
$elem.off();
- assert( 0 );
+ check( 0 );
});
if ( jQuery.fn.hover ) {
- test("hover() mouseenter mouseleave", function() {
- expect(1);
+ QUnit.test("hover() mouseenter mouseleave", function( assert ) {
+ assert.expect(1);
var times = 0,
handler1 = function() { ++times; },
@@ -828,13 +828,13 @@ if ( jQuery.fn.hover ) {
.off("mouseenter mouseleave", handler1)
.mouseenter().mouseleave();
- equal( times, 4, "hover handlers fired" );
+ assert.equal( times, 4, "hover handlers fired" );
});
}
-test("mouseover triggers mouseenter", function() {
- expect(1);
+QUnit.test("mouseover triggers mouseenter", function( assert ) {
+ assert.expect(1);
var count = 0,
elem = jQuery("
");
@@ -842,13 +842,13 @@ test("mouseover triggers mouseenter", function() {
count++;
});
elem.trigger("mouseover");
- equal(count, 1, "make sure mouseover triggers a mouseenter" );
+ assert.equal(count, 1, "make sure mouseover triggers a mouseenter" );
elem.remove();
});
-test("pointerover triggers pointerenter", function() {
- expect(1);
+QUnit.test("pointerover triggers pointerenter", function( assert ) {
+ assert.expect(1);
var count = 0,
elem = jQuery("
");
@@ -856,20 +856,20 @@ test("pointerover triggers pointerenter", function() {
count++;
});
elem.trigger("pointerover");
- equal(count, 1, "make sure pointerover triggers a pointerenter" );
+ assert.equal(count, 1, "make sure pointerover triggers a pointerenter" );
elem.remove();
});
-test("withinElement implemented with jQuery.contains()", function() {
+QUnit.test("withinElement implemented with jQuery.contains()", function( assert ) {
- expect(1);
+ assert.expect(1);
jQuery("#qunit-fixture").append("
");
jQuery("#jc-outer").on("mouseenter mouseleave", function( event ) {
- equal( this.id, "jc-outer", this.id + " " + event.type );
+ assert.equal( this.id, "jc-outer", this.id + " " + event.type );
}).trigger("mouseenter");
@@ -880,8 +880,8 @@ test("withinElement implemented with jQuery.contains()", function() {
});
-test("mouseenter, mouseleave don't catch exceptions", function() {
- expect(2);
+QUnit.test("mouseenter, mouseleave don't catch exceptions", function( assert ) {
+ assert.expect(2);
var elem = jQuery("#firstp").on( "mouseenter mouseleave", function() {
throw "an Exception";
@@ -890,27 +890,27 @@ test("mouseenter, mouseleave don't catch exceptions", function() {
try {
elem.trigger("mouseenter");
} catch (e) {
- equal( e, "an Exception", "mouseenter doesn't catch exceptions" );
+ assert.equal( e, "an Exception", "mouseenter doesn't catch exceptions" );
}
try {
elem.trigger("mouseleave");
} catch (e) {
- equal( e, "an Exception", "mouseleave doesn't catch exceptions" );
+ assert.equal( e, "an Exception", "mouseleave doesn't catch exceptions" );
}
});
if ( jQuery.fn.click ) {
- test("trigger() shortcuts", function() {
- expect(5);
+ QUnit.test("trigger() shortcuts", function( assert ) {
+ assert.expect(5);
var counter, clickCounter,
elem = jQuery("
Change location ").prependTo("#firstUL");
elem.find("a").on("click", function() {
var close = jQuery("spanx", this); // same with jQuery(this).find("span");
- equal( close.length, 0, "Context element does not exist, length must be zero" );
- ok( !close[0], "Context element does not exist, direct access to element must return undefined" );
+ assert.equal( close.length, 0, "Context element does not exist, length must be zero" );
+ assert.ok( !close[0], "Context element does not exist, direct access to element must return undefined" );
return false;
}).click();
@@ -918,7 +918,7 @@ if ( jQuery.fn.click ) {
elem.remove();
jQuery("#check1").click(function() {
- ok( true, "click event handler for checkbox gets fired twice, see #815" );
+ assert.ok( true, "click event handler for checkbox gets fired twice, see #815" );
}).click();
counter = 0;
@@ -926,14 +926,14 @@ if ( jQuery.fn.click ) {
counter++;
};
jQuery("#firstp").click();
- equal( counter, 1, "Check that click, triggers onclick event handler also" );
+ assert.equal( counter, 1, "Check that click, triggers onclick event handler also" );
clickCounter = 0;
jQuery("#simon1")[0].onclick = function() {
clickCounter++;
};
jQuery("#simon1").click();
- equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
+ assert.equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
// test that special handlers do not blow up with VML elements (#7071)
jQuery("
").appendTo("head");
@@ -943,8 +943,8 @@ if ( jQuery.fn.click ) {
}
-test("trigger() bubbling", function() {
- expect(18);
+QUnit.test("trigger() bubbling", function( assert ) {
+ assert.expect(18);
var win = 0, doc = 0, html = 0, body = 0, main = 0, ap = 0;
@@ -956,32 +956,32 @@ test("trigger() bubbling", function() {
jQuery("#ap").on("click", function(){ ap++; return false; });
jQuery("html").trigger("click");
- equal( win, 1, "HTML bubble" );
- equal( doc, 1, "HTML bubble" );
- equal( html, 1, "HTML bubble" );
+ assert.equal( win, 1, "HTML bubble" );
+ assert.equal( doc, 1, "HTML bubble" );
+ assert.equal( html, 1, "HTML bubble" );
jQuery("body").trigger("click");
- equal( win, 2, "Body bubble" );
- equal( doc, 2, "Body bubble" );
- equal( html, 2, "Body bubble" );
- equal( body, 1, "Body bubble" );
+ assert.equal( win, 2, "Body bubble" );
+ assert.equal( doc, 2, "Body bubble" );
+ assert.equal( html, 2, "Body bubble" );
+ assert.equal( body, 1, "Body bubble" );
jQuery("#qunit-fixture").trigger("click");
- equal( win, 3, "Main bubble" );
- equal( doc, 3, "Main bubble" );
- equal( html, 3, "Main bubble" );
- equal( body, 2, "Main bubble" );
- equal( main, 1, "Main bubble" );
+ assert.equal( win, 3, "Main bubble" );
+ assert.equal( doc, 3, "Main bubble" );
+ assert.equal( html, 3, "Main bubble" );
+ assert.equal( body, 2, "Main bubble" );
+ assert.equal( main, 1, "Main bubble" );
jQuery("#ap").trigger("click");
- equal( doc, 3, "ap bubble" );
- equal( html, 3, "ap bubble" );
- equal( body, 2, "ap bubble" );
- equal( main, 1, "ap bubble" );
- equal( ap, 1, "ap bubble" );
+ assert.equal( doc, 3, "ap bubble" );
+ assert.equal( html, 3, "ap bubble" );
+ assert.equal( body, 2, "ap bubble" );
+ assert.equal( main, 1, "ap bubble" );
+ assert.equal( ap, 1, "ap bubble" );
jQuery( document ).trigger("click");
- equal( win, 4, "doc bubble" );
+ assert.equal( win, 4, "doc bubble" );
// manually clean up events from elements outside the fixture
jQuery(window).off("click");
@@ -989,15 +989,15 @@ test("trigger() bubbling", function() {
jQuery("html, body, #qunit-fixture").off("click");
});
-test("trigger(type, [data], [fn])", function() {
- expect(16);
+QUnit.test("trigger(type, [data], [fn])", function( assert ) {
+ assert.expect(16);
var $elem, pass, form, elem2,
handler = function(event, a, b, c) {
- equal( event.type, "click", "check passed data" );
- equal( a, 1, "check passed data" );
- equal( b, "2", "check passed data" );
- equal( c, "abc", "check passed data" );
+ assert.equal( event.type, "click", "check passed data" );
+ assert.equal( a, 1, "check passed data" );
+ assert.equal( b, "2", "check passed data" );
+ assert.equal( c, "abc", "check passed data" );
return "test";
};
@@ -1005,16 +1005,16 @@ test("trigger(type, [data], [fn])", function() {
// Simulate a "native" click
$elem[0].click = function(){
- ok( true, "Native call was triggered" );
+ assert.ok( true, "Native call was triggered" );
};
jQuery( document ).on("mouseenter", "#firstp", function(){
- ok( true, "Trigger mouseenter bound by on" );
+ assert.ok( true, "Trigger mouseenter bound by on" );
});
jQuery( document ).on("mouseleave", "#firstp", function(){
- ok( true, "Trigger mouseleave bound by on" );
+ assert.ok( true, "Trigger mouseleave bound by on" );
});
$elem.trigger("mouseenter");
@@ -1029,12 +1029,12 @@ test("trigger(type, [data], [fn])", function() {
// Simulate a "native" click
$elem[0].click = function(){
- ok( false, "Native call was triggered" );
+ assert.ok( false, "Native call was triggered" );
};
// Trigger only the handlers (no native)
// Triggers 5
- equal( $elem.triggerHandler("click", [1, "2", "abc"]), "test", "Verify handler response" );
+ assert.equal( $elem.triggerHandler("click", [1, "2", "abc"]), "test", "Verify handler response" );
pass = true;
try {
@@ -1044,7 +1044,7 @@ test("trigger(type, [data], [fn])", function() {
} catch( e ) {
pass = false;
}
- ok( pass, "Trigger focus on hidden element" );
+ assert.ok( pass, "Trigger focus on hidden element" );
pass = true;
try {
@@ -1052,13 +1052,13 @@ test("trigger(type, [data], [fn])", function() {
} catch ( e ) {
pass = false;
}
- ok( pass, "Trigger on a table with a colon in the even type, see #3533" );
+ assert.ok( pass, "Trigger on a table with a colon in the even type, see #3533" );
form = jQuery("
").appendTo("body");
// Make sure it can be prevented locally
form.on( "submit", function(){
- ok( true, "Local `on` still works." );
+ assert.ok( true, "Local `on` still works." );
return false;
});
@@ -1068,7 +1068,7 @@ test("trigger(type, [data], [fn])", function() {
form.off("submit");
jQuery(document).on( "submit", function(){
- ok( true, "Make sure bubble works up to document." );
+ assert.ok( true, "Make sure bubble works up to document." );
return false;
});
@@ -1080,8 +1080,8 @@ test("trigger(type, [data], [fn])", function() {
form.remove();
});
-test( "submit event bubbles on copied forms (#11649)", function() {
- expect( 3 );
+QUnit.test( "submit event bubbles on copied forms (#11649)", function( assert ) {
+ assert.expect( 3 );
var $formByClone, $formByHTML,
$testForm = jQuery("#testForm"),
@@ -1092,7 +1092,7 @@ test( "submit event bubbles on copied forms (#11649)", function() {
e.preventDefault();
}
function delegatedSubmit() {
- ok( true, "Make sure submit event bubbles up." );
+ assert.ok( true, "Make sure submit event bubbles up." );
return false;
}
@@ -1116,8 +1116,8 @@ test( "submit event bubbles on copied forms (#11649)", function() {
$testForm.off( "submit", noSubmit );
});
-test( "change event bubbles on copied forms (#11796)", function(){
- expect( 3 );
+QUnit.test( "change event bubbles on copied forms (#11796)", function( assert ){
+ assert.expect( 3 );
var $formByClone, $formByHTML,
$form = jQuery("#form"),
@@ -1125,7 +1125,7 @@ test( "change event bubbles on copied forms (#11796)", function(){
$wrapperDiv = jQuery("
").appendTo( $fixture );
function delegatedChange() {
- ok( true, "Make sure change event bubbles up." );
+ assert.ok( true, "Make sure change event bubbles up." );
return false;
}
@@ -1148,8 +1148,8 @@ test( "change event bubbles on copied forms (#11796)", function(){
$fixture.off( "change", "form", delegatedChange );
});
-test("trigger(eventObject, [data], [fn])", function() {
- expect(28);
+QUnit.test("trigger(eventObject, [data], [fn])", function( assert ) {
+ assert.expect(28);
var event,
$parent = jQuery("
").appendTo("body"),
@@ -1158,29 +1158,29 @@ test("trigger(eventObject, [data], [fn])", function() {
$parent.get( 0 ).style.display = "none";
event = jQuery.Event("noNew");
- ok( event !== window, "Instantiate jQuery.Event without the 'new' keyword" );
- equal( event.type, "noNew", "Verify its type" );
+ assert.ok( event !== window, "Instantiate jQuery.Event without the 'new' keyword" );
+ assert.equal( event.type, "noNew", "Verify its type" );
- equal( event.isDefaultPrevented(), false, "Verify isDefaultPrevented" );
- equal( event.isPropagationStopped(), false, "Verify isPropagationStopped" );
- equal( event.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );
+ assert.equal( event.isDefaultPrevented(), false, "Verify isDefaultPrevented" );
+ assert.equal( event.isPropagationStopped(), false, "Verify isPropagationStopped" );
+ assert.equal( event.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );
event.preventDefault();
- equal( event.isDefaultPrevented(), true, "Verify isDefaultPrevented" );
+ assert.equal( event.isDefaultPrevented(), true, "Verify isDefaultPrevented" );
event.stopPropagation();
- equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
+ assert.equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
event.isPropagationStopped = function(){ return false; };
event.stopImmediatePropagation();
- equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
- equal( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
+ assert.equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" );
+ assert.equal( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" );
$parent.on("foo",function( e ) {
// Tries bubbling
- equal( e.type, "foo", "Verify event type when passed passing an event object" );
- equal( e.target.id, "child", "Verify event.target when passed passing an event object" );
- equal( e.currentTarget.id, "par", "Verify event.currentTarget when passed passing an event object" );
- equal( e.secret, "boo!", "Verify event object's custom attribute when passed passing an event object" );
+ assert.equal( e.type, "foo", "Verify event type when passed passing an event object" );
+ assert.equal( e.target.id, "child", "Verify event.target when passed passing an event object" );
+ assert.equal( e.currentTarget.id, "par", "Verify event.currentTarget when passed passing an event object" );
+ assert.equal( e.secret, "boo!", "Verify event object's custom attribute when passed passing an event object" );
});
// test with an event object
@@ -1194,20 +1194,20 @@ test("trigger(eventObject, [data], [fn])", function() {
$parent.off();
function error(){
- ok( false, "This assertion shouldn't be reached");
+ assert.ok( false, "This assertion shouldn't be reached");
}
$parent.on("foo", error );
$child.on("foo",function(e, a, b, c ){
- equal( arguments.length, 4, "Check arguments length");
- equal( a, 1, "Check first custom argument");
- equal( b, 2, "Check second custom argument");
- equal( c, 3, "Check third custom argument");
+ assert.equal( arguments.length, 4, "Check arguments length");
+ assert.equal( a, 1, "Check first custom argument");
+ assert.equal( b, 2, "Check second custom argument");
+ assert.equal( c, 3, "Check third custom argument");
- equal( e.isDefaultPrevented(), false, "Verify isDefaultPrevented" );
- equal( e.isPropagationStopped(), false, "Verify isPropagationStopped" );
- equal( e.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );
+ assert.equal( e.isDefaultPrevented(), false, "Verify isDefaultPrevented" );
+ assert.equal( e.isPropagationStopped(), false, "Verify isPropagationStopped" );
+ assert.equal( e.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" );
// Skips both errors
e.stopImmediatePropagation();
@@ -1221,7 +1221,7 @@ test("trigger(eventObject, [data], [fn])", function() {
event = new jQuery.Event("foo");
$child.trigger( event, [1,2,3] ).off();
- equal( event.result, "result", "Check event.result attribute");
+ assert.equal( event.result, "result", "Check event.result attribute");
// Will error if it bubbles
$child.triggerHandler("foo");
@@ -1232,25 +1232,25 @@ test("trigger(eventObject, [data], [fn])", function() {
// Ensure triggerHandler doesn't molest its event object (#xxx)
event = jQuery.Event( "zowie" );
jQuery( document ).triggerHandler( event );
- equal( event.type, "zowie", "Verify its type" );
- equal( event.isPropagationStopped(), false, "propagation not stopped" );
- equal( event.isDefaultPrevented(), false, "default not prevented" );
+ assert.equal( event.type, "zowie", "Verify its type" );
+ assert.equal( event.isPropagationStopped(), false, "propagation not stopped" );
+ assert.equal( event.isDefaultPrevented(), false, "default not prevented" );
});
-test(".trigger() bubbling on disconnected elements (#10489)", function() {
- expect(2);
+QUnit.test(".trigger() bubbling on disconnected elements (#10489)", function( assert ) {
+ assert.expect(2);
jQuery( window ).on( "click", function(){
- ok( false, "click fired on window" );
+ assert.ok( false, "click fired on window" );
});
jQuery( "
" )
.on( "click", function() {
- ok( true, "click fired on div" );
+ assert.ok( true, "click fired on div" );
})
.find( "p" )
.on( "click", function() {
- ok( true, "click fired on p" );
+ assert.ok( true, "click fired on p" );
})
.trigger("click")
.off( "click" )
@@ -1261,18 +1261,18 @@ test(".trigger() bubbling on disconnected elements (#10489)", function() {
jQuery( window ).off( "click" );
});
-test(".trigger() doesn't bubble load event (#10717)", function() {
- expect(1);
+QUnit.test(".trigger() doesn't bubble load event (#10717)", function( assert ) {
+ assert.expect(1);
jQuery( window ).on( "load", function(){
- ok( false, "load fired on window" );
+ assert.ok( false, "load fired on window" );
});
// It's not an image, but as long as it fires load...
jQuery("
")
.appendTo( "body" )
.on( "load", function() {
- ok( true, "load fired on img" );
+ assert.ok( true, "load fired on img" );
})
.trigger( "load" )
.remove();
@@ -1280,8 +1280,8 @@ test(".trigger() doesn't bubble load event (#10717)", function() {
jQuery( window ).off( "load" );
});
-test("Delegated events in SVG (#10791; #13180)", function() {
- expect(2);
+QUnit.test("Delegated events in SVG (#10791; #13180)", function( assert ) {
+ assert.expect(2);
var useElem, e,
svg = jQuery(
@@ -1296,10 +1296,10 @@ test("Delegated events in SVG (#10791; #13180)", function() {
jQuery("#qunit-fixture")
.append( svg )
.on( "click", "#svg-by-id", function() {
- ok( true, "delegated id selector" );
+ assert.ok( true, "delegated id selector" );
})
.on( "click", "[class~='svg-by-class']", function() {
- ok( true, "delegated class selector" );
+ assert.ok( true, "delegated class selector" );
})
.find( "#svg-by-id, [class~='svg-by-class']" )
.trigger("click")
@@ -1317,8 +1317,8 @@ test("Delegated events in SVG (#10791; #13180)", function() {
jQuery("#qunit-fixture").off("click");
});
-test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", function() {
- expect(5);
+QUnit.test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", function( assert ) {
+ assert.expect(5);
// Alias names like "id" cause havoc
var form = jQuery(
@@ -1333,7 +1333,7 @@ test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", functi
jQuery("body")
.on( "submit", "#myform", function() {
- ok( true, "delegated id selector with aliased id" );
+ assert.ok( true, "delegated id selector with aliased id" );
})
.find("#myform")
.trigger("submit")
@@ -1343,7 +1343,7 @@ test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", functi
form.append("
");
jQuery("body")
.on( "submit", "#myform", function() {
- ok( true, "delegated id selector with aliased disabled" );
+ assert.ok( true, "delegated id selector with aliased disabled" );
})
.find("#myform")
.trigger("submit")
@@ -1353,10 +1353,10 @@ test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", functi
form
.append( "
Zing " )
.on( "click", "#nestyDisabledBtn", function() {
- ok( true, "click on enabled/disabled button with nesty elements" );
+ assert.ok( true, "click on enabled/disabled button with nesty elements" );
})
.on( "mouseover", "#nestyDisabledBtn", function() {
- ok( true, "mouse on enabled/disabled button with nesty elements" );
+ assert.ok( true, "mouse on enabled/disabled button with nesty elements" );
})
.find( "span" )
.trigger( "click" ) // yep
@@ -1372,8 +1372,8 @@ test("Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", functi
form.remove();
});
-test("Submit event can be stopped (#11049)", function() {
- expect(1);
+QUnit.test("Submit event can be stopped (#11049)", function( assert ) {
+ assert.expect(1);
// Since we manually bubble in IE, make sure inner handlers get a chance to cancel
var form = jQuery(
@@ -1386,14 +1386,14 @@ test("Submit event can be stopped (#11049)", function() {
jQuery( "body" )
.on( "submit", function() {
- ok( true, "submit bubbled on first handler" );
+ assert.ok( true, "submit bubbled on first handler" );
return false;
})
.find( "#myform input[type=submit]" )
.each( function(){ this.click(); } )
.end()
.on( "submit", function() {
- ok( false, "submit bubbled on second handler" );
+ assert.ok( false, "submit bubbled on second handler" );
return false;
})
.find( "#myform input[type=submit]" )
@@ -1416,42 +1416,43 @@ test("Submit event can be stopped (#11049)", function() {
// handler making it impossible to feature-detect the support.
if ( window.onbeforeunload === null &&
!/(ipad|iphone|ipod|android 2\.3)/i.test( navigator.userAgent ) ) {
- asyncTest("on(beforeunload)", 1, function() {
+ QUnit.test("on(beforeunload)", 1, function( assert ) {
var iframe = jQuery(jQuery.parseHTML("