Test: Update index.html to new QUnit format. Close gh-1061.

Depends on jquery/sizzle#177, included with the Sizzle submodule in this commit.
This commit is contained in:
Timo Tijhof 2012-12-11 01:07:07 +01:00 committed by Dave Methvin
parent d41b983259
commit 55313d32a2
9 changed files with 41 additions and 43 deletions

@ -1 +1 @@
Subproject commit 8d91687e64f137fac70a8f88d361c5bbb688299f
Subproject commit 71467207315eaac67dc6ba00992fe0f7998a8cb4

View File

@ -94,7 +94,7 @@ function testSubproject( label, url, risTests ) {
fixture = page.find("[id='qunit-fixture']");
fixtureHTML = fixture.html();
fixture.empty();
while ( fixture.length && !fixture.prevAll("[id^='qunit-']").length ) {
while ( fixture.length && !fixture.prevAll("[id='qunit']").length ) {
fixture = fixture.parent();
}
fixture = fixture.add( fixture.nextAll() );
@ -112,7 +112,7 @@ function testSubproject( label, url, risTests ) {
// Replace the current fixture, including content outside of #qunit-fixture
var oldFixture = originaljQuery("#qunit-fixture");
while ( oldFixture.length && !oldFixture.prevAll("[id^='qunit-']").length ) {
while ( oldFixture.length && !oldFixture.prevAll("[id='qunit']").length ) {
oldFixture = oldFixture.parent();
}
oldFixture.nextAll().remove();

View File

@ -82,16 +82,9 @@
</head>
<body id="body">
<h1 id="qunit-header"><a href="/jquery/test/index.html">jQuery Test Suite</a></h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit"></div>
<!-- Test HTML -->
<div id="nothiddendiv" style="height:1px;background:white;" class="nothiddendiv">
<div id="nothiddendivchild"></div>
</div>
<!-- this iframe is outside the #qunit-fixture so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
<iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe>
<dl id="dl" style="position:absolute;top:-32767px;left:-32767px;width:1px">
@ -110,6 +103,9 @@
<p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
</div>
<div id="nothiddendiv" style="height:1px;background:white;" class="nothiddendiv">
<div id="nothiddendivchild"></div>
</div>
<span id="name+value"></span>
<p id="first">Try them out:</p>
<ul id="firstUL"></ul>

View File

@ -978,7 +978,7 @@ test( "val(select) after form.reset() (Bug #2551)", function() {
var testAddClass = function( valueObj ) {
expect( 9 );
var div = jQuery("div");
var div = jQuery("#qunit-fixture div");
div.addClass( valueObj("test") );
var pass = true;
for ( var i = 0; i < div.size(); i++ ) {
@ -1029,8 +1029,8 @@ test( "addClass(Function)", function() {
});
test( "addClass(Function) with incoming value", function() {
expect( 54 );
var div = jQuery("div"),
expect( 52 );
var div = jQuery("#qunit-fixture div"),
old = div.map(function() {
return jQuery(this).attr("class") || "";
});
@ -1054,7 +1054,7 @@ test( "addClass(Function) with incoming value", function() {
var testRemoveClass = function(valueObj) {
expect( 8 );
var $set = jQuery("div"),
var $set = jQuery("#qunit-fixture div"),
div = document.createElement("div");
$set.addClass("test").removeClass( valueObj("test") );
@ -1102,9 +1102,9 @@ test( "removeClass(Function) - simple", function() {
});
test( "removeClass(Function) with incoming value", function() {
expect( 54 );
expect( 52 );
var $divs = jQuery("div").addClass("test"), old = $divs.map(function() {
var $divs = jQuery("#qunit-fixture div").addClass("test"), old = $divs.map(function() {
return jQuery( this ).attr("class");
});

View File

@ -1491,8 +1491,8 @@ test(".live()/.die()", function() {
var submit = 0, div = 0, livea = 0, liveb = 0;
jQuery("div").live("submit", function(){ submit++; return false; });
jQuery("div").live("click", function(){ div++; });
jQuery("#qunit-fixture div").live("submit", function(){ submit++; return false; });
jQuery("#qunit-fixture div").live("click", function(){ div++; });
jQuery("div#nothiddendiv").live("click", function(){ livea++; });
jQuery("div#nothiddendivchild").live("click", function(){ liveb++; });
@ -1571,13 +1571,13 @@ test(".live()/.die()", function() {
jQuery("div#nothiddendivchild").die("click");
jQuery("div#nothiddendiv").die("click");
jQuery("div").die("click");
jQuery("div").die("submit");
jQuery("#qunit-fixture div").die("click");
jQuery("#qunit-fixture div").die("submit");
// Test binding with a different context
var clicked = 0, container = jQuery("#qunit-fixture")[0];
jQuery("#foo", container).live("click", function(e){ clicked++; });
jQuery("div").trigger("click");
jQuery("#qunit-fixture div").trigger("click");
jQuery("#foo").trigger("click");
jQuery("#qunit-fixture").trigger("click");
jQuery("body").trigger("click");
@ -2022,8 +2022,8 @@ test(".delegate()/.undelegate()", function() {
var submit = 0, div = 0, livea = 0, liveb = 0;
jQuery("#body").delegate("div", "submit", function(){ submit++; return false; });
jQuery("#body").delegate("div", "click", function(){ div++; });
jQuery("#body").delegate("#qunit-fixture div", "submit", function(){ submit++; return false; });
jQuery("#body").delegate("#qunit-fixture div", "click", function(){ div++; });
jQuery("#body").delegate("div#nothiddendiv", "click", function(){ livea++; });
jQuery("#body").delegate("div#nothiddendivchild", "click", function(){ liveb++; });
@ -2102,13 +2102,13 @@ test(".delegate()/.undelegate()", function() {
jQuery("#body").undelegate("div#nothiddendivchild", "click");
jQuery("#body").undelegate("div#nothiddendiv", "click");
jQuery("#body").undelegate("div", "click");
jQuery("#body").undelegate("div", "submit");
jQuery("#body").undelegate("#qunit-fixture div", "click");
jQuery("#body").undelegate("#qunit-fixture div", "submit");
// Test binding with a different context
var clicked = 0, container = jQuery("#qunit-fixture")[0];
jQuery("#qunit-fixture").delegate("#foo", "click", function(e){ clicked++; });
jQuery("div").trigger("click");
jQuery("#qunit-fixture div").trigger("click");
jQuery("#foo").trigger("click");
jQuery("#qunit-fixture").trigger("click");
jQuery("body").trigger("click");

View File

@ -1459,7 +1459,7 @@ test( "clone()", function() {
equal( jQuery(form).clone().children().length, 1, "Make sure we just get the form back." );
body = jQuery("body").clone();
equal( body.children()[ 0 ].id, "qunit-header", "Make sure cloning body works" );
equal( body.children()[ 0 ].id, "qunit", "Make sure cloning body works" );
body.remove();
});
@ -1612,7 +1612,7 @@ var testHtml = function( valueObj ) {
expected.push("B");
actual.push( childNodeNames( this ) );
});
equal( expected.length, 6, "Expecting many parents" );
equal( expected.length, 7, "Expecting many parents" );
deepEqual( actual, expected, "Correct childNodes after setting HTML" );
actual = []; expected = [];

View File

@ -487,13 +487,13 @@ test("offsetParent", function(){
equal( body.length, 1, "Only one offsetParent found." );
equal( body[0], document.documentElement, "The html element is the offsetParent of the body." );
var header = jQuery("#qunit-header").offsetParent();
var header = jQuery("#qunit").offsetParent();
equal( header.length, 1, "Only one offsetParent found." );
equal( header[0], document.documentElement, "The html element is the offsetParent of the body." );
equal( header[0], document.documentElement, "The html element is the offsetParent of #qunit." );
var div = jQuery("#nothiddendivchild").offsetParent();
equal( div.length, 1, "Only one offsetParent found." );
equal( div[0], document.documentElement, "The html element is the offsetParent of the body." );
equal( div[0], document.getElementById("qunit-fixture"), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
jQuery("#nothiddendiv").css("position", "relative");

View File

@ -7,10 +7,12 @@ module("selector - jQuery only", { teardown: moduleTeardown });
test("element - jQuery only", function() {
expect( 7 );
deepEqual( jQuery("p", document.getElementsByTagName("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
deepEqual( jQuery("p", "div").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
deepEqual( jQuery("p", jQuery("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
deepEqual( jQuery("div").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
var fixture = document.getElementById("qunit-fixture");
deepEqual( jQuery("p", fixture).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a Node context." );
deepEqual( jQuery("p", "#qunit-fixture").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a selector context." );
deepEqual( jQuery("p", jQuery("#qunit-fixture")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a jQuery object context." );
deepEqual( jQuery("#qunit-fixture").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context via .find()." );
ok( jQuery("#length").length, "<input name=\"length\"> cannot be found under IE, see #945" );
ok( jQuery("#lengthtest input").length, "<input name=\"length\"> cannot be found under IE, see #945" );
@ -44,7 +46,7 @@ if ( jQuery.css ) {
test("pseudo - visibility", function() {
expect( 9 );
t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] );
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"] );

View File

@ -9,7 +9,7 @@ test( "find(String)", function() {
equal( j.find("div").length, 0, "Check node,textnode,comment to find zero divs" );
equal( j.find("div").andSelf().length, 3, "Check node,textnode,comment to find zero divs, but preserves pushStack" );
deepEqual( jQuery("#qunit-fixture").find("> div").get(), q( "foo", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" );
deepEqual( jQuery("#qunit-fixture").find("> div").get(), q( "foo", "nothiddendiv", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" );
deepEqual( jQuery("#qunit-fixture").find("> #foo, > #moretests").get(), q( "foo", "moretests" ), "find child elements" );
deepEqual( jQuery("#qunit-fixture").find("> #foo > p").get(), q( "sndp", "en", "sap" ), "find child elements" );
@ -286,8 +286,8 @@ test("closest()", function() {
deepEqual( jQuery("body").closest("div").get(), [], "closest(div)" );
deepEqual( jQuery("#qunit-fixture").closest("span,#html").get(), q("html"), "closest(span,#html)" );
deepEqual( jQuery("div:eq(1)").closest("div:first").get(), [], "closest(div:first)" );
deepEqual( jQuery("div").closest("body:first div:last").get(), q("fx-tests"), "closest(body:first div:last)" );
deepEqual( jQuery("#qunit-fixture").closest("div:first").get(), [], "closest(div:first)" );
deepEqual( jQuery("#qunit-fixture div").closest("body:first div:last").get(), q("fx-tests"), "closest(body:first div:last)" );
// Test .closest() limited by the context
var jq = jQuery("#nothiddendivchild");
@ -312,15 +312,15 @@ test("closest(jQuery)", function() {
expect(8);
var $child = jQuery("#nothiddendivchild"),
$parent = jQuery("#nothiddendiv"),
$main = jQuery("#qunit-fixture"),
$sibling = jQuery("#foo"),
$body = jQuery("body");
ok( $child.closest( $parent ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') )" );
ok( $child.closest( $parent[0] ).is("#nothiddendiv"), "closest( jQuery('#nothiddendiv') ) :: node" );
ok( $child.closest( $child ).is("#nothiddendivchild"), "child is included" );
ok( $child.closest( $child[0] ).is("#nothiddendivchild"), "child is included :: node" );
equal( $child.closest( document.createElement("div") ).length, 0, "created element is not related" );
equal( $child.closest( $main ).length, 0, "Main not a parent of child" );
equal( $child.closest( $main[0] ).length, 0, "Main not a parent of child :: node" );
equal( $child.closest( $sibling ).length, 0, "Sibling not a parent of child" );
equal( $child.closest( $sibling[0] ).length, 0, "Sibling not a parent of child :: node" );
ok( $child.closest( $body.add($parent) ).is("#nothiddendiv"), "Closest ancestor retrieved." );
});