X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=e1c373301b3098118b5ff5eaa349d2058596cb11;hb=b1e161466cb7f68bc7447ffd580395764715d9ca;hp=451bd71c7b938b7133df26e7a4fd06832fe93eeb;hpb=c0294278db40da764a98ea1c1506548e539213c7;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index 451bd71..e1c3733 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -291,9 +291,10 @@ test("jQuery(selector, xml).text(str) - Loaded via XML document", function() { stop(); jQuery.get('data/dashboard.xml', function(xml) { // tests for #1419 where IE was a problem - equals( jQuery("tab:first", xml).text(), "blabla", "Verify initial text correct" ); - jQuery("tab:first", xml).text("newtext"); - equals( jQuery("tab:first", xml).text(), "newtext", "Verify new text correct" ); + var tab = jQuery("tab", xml).eq(0); + equals( tab.text(), "blabla", "Verify initial text correct" ); + tab.text("newtext"); + equals( tab.text(), "newtext", "Verify new text correct" ); start(); }); }); @@ -545,6 +546,62 @@ if ( !isLocal ) { }); } +test("attr('tabindex')", function() { + expect(5); + + // tabindex 0 + equals(jQuery('#listWithTabIndex').attr('tabindex'), 0, 'tabindex of 0'); + + // positive tabindex + equals(jQuery('#linkWithTabIndex').attr('tabindex'), 2, 'tabindex of 2'); + + // negative tabindex + equals(jQuery('#linkWithNegativeTabIndex').attr('tabindex'), -1, 'negative tabindex'); + + // regular element without a tabindex + equals(jQuery('#divWithNoTabIndex').attr('tabindex'), undefined, 'no tabindex, not tabbable by default'); + + // link without a tabindex + equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), undefined, 'no tabindex, tabbable by default'); +}); + +test("attr('tabindex', value)", function() { + expect(9); + + var element = jQuery('#divWithNoTabIndex'); + equals(element.attr('tabindex'), undefined, 'start with no tabindex'); + + // set a positive string + element.attr('tabindex', '1'); + equals(element.attr('tabindex'), 1, 'set tabindex to 1 (string)'); + + // set a zero string + element.attr('tabindex', '0'); + equals(element.attr('tabindex'), 0, 'set tabindex to 0 (string)'); + + // set a negative string + element.attr('tabindex', '-1'); + equals(element.attr('tabindex'), -1, 'set tabindex to -1 (string)'); + + // set a positive number + element.attr('tabindex', 1); + equals(element.attr('tabindex'), 1, 'set tabindex to 1 (number)'); + + // set a zero number + element.attr('tabindex', 0); + equals(element.attr('tabindex'), 0, 'set tabindex to 0 (number)'); + + // set a negative number + element.attr('tabindex', -1); + equals(element.attr('tabindex'), -1, 'set tabindex to -1 (number)'); + + element = jQuery('#linkWithTabIndex'); + equals(element.attr('tabindex'), 2, 'start with tabindex 2'); + + element.attr('tabindex', -1); + equals(element.attr('tabindex'), -1, 'set negative tabindex'); +}); + test("css(String|Hash)", function() { expect(19); @@ -1111,10 +1168,12 @@ test("clone() on XML nodes", function() { stop(); jQuery.get("data/dashboard.xml", function (xml) { var root = jQuery(xml.documentElement).clone(); - jQuery("tab:first", xml).text("origval"); - jQuery("tab:first", root).text("cloneval"); - equals(jQuery("tab:first", xml).text(), "origval", "Check original XML node was correctly set"); - equals(jQuery("tab:first", root).text(), "cloneval", "Check cloned XML node was correctly set"); + var origTab = jQuery("tab", xml).eq(0); + var cloneTab = jQuery("tab", root).eq(0); + origTab.text("origval"); + cloneTab.text("cloneval"); + equals(origTab.text(), "origval", "Check original XML node was correctly set"); + equals(cloneTab.text(), "cloneval", "Check cloned XML node was correctly set"); start(); }); }); @@ -1379,7 +1438,7 @@ test("siblings([String])", function() { isSet( jQuery("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" ); isSet( jQuery("#sndp").siblings(":has(code)").get(), q("sap"), "Check for filtered siblings (has code child element)" ); isSet( jQuery("#sndp").siblings(":has(a)").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" ); - isSet( jQuery("#foo").siblings("form, b").get(), q("form", "lengthtest", "testForm", "floatTest"), "Check for multiple filters" ); + isSet( jQuery("#foo").siblings("form, b").get(), q("form", "lengthtest", "name-tests", "testForm", "floatTest"), "Check for multiple filters" ); var set = document.querySelectorAll ? q("en", "sap", "sndp") : q("sndp", "sap", "en"); isSet( jQuery("#en, #sndp").siblings().get(), set, "Check for unique results from siblings" ); });