diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index fa59a9f7..641165f4 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -34,7 +34,7 @@ function testWidth( val ) { equals( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." ); equals( blah.width(), null, "Make sure 'null' is returned on an empty set"); - jQuery.removeData($div[0], 'olddisplay', true); + jQuery.removeData($div[0], "olddisplay", true); } test("width()", function() { @@ -83,7 +83,7 @@ function testHeight( val ) { equals( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." ); equals( blah.height(), null, "Make sure 'null' is returned on an empty set"); - jQuery.removeData($div[0], 'olddisplay', true); + jQuery.removeData($div[0], "olddisplay", true); } test("height()", function() { @@ -132,7 +132,7 @@ test("innerWidth()", function() { equals( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." ); div.remove(); - jQuery.removeData($div[0], 'olddisplay', true); + jQuery.removeData($div[0], "olddisplay", true); }); test("innerHeight()", function() { @@ -161,7 +161,7 @@ test("innerHeight()", function() { equals( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." ); div.remove(); - jQuery.removeData($div[0], 'olddisplay', true); + jQuery.removeData($div[0], "olddisplay", true); }); test("outerWidth()", function() { @@ -191,7 +191,7 @@ test("outerWidth()", function() { equals( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." ); div.remove(); - jQuery.removeData($div[0], 'olddisplay', true); + jQuery.removeData($div[0], "olddisplay", true); }); test("outerHeight()", function() { @@ -220,5 +220,5 @@ test("outerHeight()", function() { equals( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." ); div.remove(); - jQuery.removeData($div[0], 'olddisplay', true); + jQuery.removeData($div[0], "olddisplay", true); }); diff --git a/test/unit/effects.js b/test/unit/effects.js index 4f678511..0979a4c1 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -62,7 +62,7 @@ test("show()", function() { }); // #show-tests * is set display: none in CSS - jQuery("#main").append('
foo
').appendTo( $parent ); + var $parent = jQuery("").hide().appendTo("body"), + $child = jQuery("foo
").appendTo( $parent ); var event = jQuery.Event("noNew"); ok( event != window, "Instantiate jQuery.Event without the 'new' keyword" ); @@ -920,21 +920,21 @@ test("trigger(eventObject, [data], [fn])", function() { equals( event.isPropagationStopped(), true, "Verify isPropagationStopped" ); equals( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" ); - $parent.bind('foo',function(e){ + $parent.bind("foo",function(e){ // Tries bubbling - equals( e.type, 'foo', 'Verify event type when passed passing an event object' ); - equals( e.target.id, 'child', 'Verify event.target when passed passing an event object' ); - equals( e.currentTarget.id, 'par', 'Verify event.target when passed passing an event object' ); - equals( e.secret, 'boo!', 'Verify event object\'s custom attribute when passed passing an event object' ); + equals( e.type, "foo", "Verify event type when passed passing an event object" ); + equals( e.target.id, "child", "Verify event.target when passed passing an event object" ); + equals( e.currentTarget.id, "par", "Verify event.target when passed passing an event object" ); + equals( e.secret, "boo!", "Verify event object's custom attribute when passed passing an event object" ); }); // test with an event object event = new jQuery.Event("foo"); - event.secret = 'boo!'; + event.secret = "boo!"; $child.trigger(event); // test with a literal object - $child.trigger({type:'foo', secret:'boo!'}); + $child.trigger({type: "foo", secret: "boo!"}); $parent.unbind(); @@ -942,9 +942,9 @@ test("trigger(eventObject, [data], [fn])", function() { ok( false, "This assertion shouldn't be reached"); } - $parent.bind('foo', error ); + $parent.bind("foo", error ); - $child.bind('foo',function(e, a, b, c ){ + $child.bind("foo",function(e, a, b, c ){ equals( arguments.length, 4, "Check arguments length"); equals( a, 1, "Check first custom argument"); equals( b, 2, "Check second custom argument"); @@ -962,14 +962,14 @@ test("trigger(eventObject, [data], [fn])", function() { // We should add this back in when we want to test the order // in which event handlers are iterated. - //$child.bind('foo', error ); + //$child.bind("foo", error ); event = new jQuery.Event("foo"); $child.trigger( event, [1,2,3] ).unbind(); equals( event.result, "result", "Check event.result attribute"); // Will error if it bubbles - $child.triggerHandler('foo'); + $child.triggerHandler("foo"); $child.unbind(); $parent.unbind().remove(); @@ -1000,12 +1000,12 @@ test("jQuery.Event.currentTarget", function(){ expect(1); var counter = 0, - $elem = jQuery('').click(function(e){ + $elem = jQuery("").click(function(e){ equals( e.currentTarget, this, "Check currentTarget on "+(counter++?"native":"fake") +" event" ); }); // Fake event - $elem.trigger('click'); + $elem.trigger("click"); // Cleanup $elem.unbind(); @@ -1018,7 +1018,7 @@ test("toggle(Function, Function, ...)", function() { fn1 = function(e) { count++; }, fn2 = function(e) { count--; }, preventDefault = function(e) { e.preventDefault() }, - link = jQuery('#mark'); + link = jQuery("#mark"); link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click(); equals( count, 1, "Check for toggle(fn, fn)" ); @@ -1062,8 +1062,8 @@ test("toggle(Function, Function, ...)", function() { $div.click(); equals( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2"); - $div.unbind('click',fns[0]); - var data = jQuery._data( $div[0], 'events' ); + $div.unbind("click",fns[0]); + var data = jQuery._data( $div[0], "events" ); ok( !data, "Unbinding one function from toggle unbinds them all"); // manually clean up detached elements @@ -1178,12 +1178,12 @@ test(".live()/.die()", function() { jQuery("div").die("submit"); // Test binding with a different context - var clicked = 0, container = jQuery('#main')[0]; + var clicked = 0, container = jQuery("#main")[0]; jQuery("#foo", container).live("click", function(e){ clicked++; }); - jQuery("div").trigger('click'); - jQuery("#foo").trigger('click'); - jQuery("#main").trigger('click'); - jQuery("body").trigger('click'); + jQuery("div").trigger("click"); + jQuery("#foo").trigger("click"); + jQuery("#main").trigger("click"); + jQuery("body").trigger("click"); equals( clicked, 2, "live with a context" ); // Make sure the event is actually stored on the context @@ -1191,7 +1191,7 @@ test(".live()/.die()", function() { // Test unbinding with a different context jQuery("#foo", container).die("click"); - jQuery("#foo").trigger('click'); + jQuery("#foo").trigger("click"); equals( clicked, 2, "die with a context"); // Test binding with event data @@ -1273,9 +1273,9 @@ test(".live()/.die()", function() { // Make sure we don't loose the target by DOM modifications // after the bubble already reached the liveHandler - var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('').get(0); + var livec = 0, elemDiv = jQuery("#nothiddendivchild").html("").get(0); - jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(''); }); + jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(""); }); jQuery("#nothiddendivchild").live("click", function(e){ if(e.target) {livec++;} }); jQuery("#nothiddendiv span").click(); @@ -1290,20 +1290,20 @@ test(".live()/.die()", function() { var lived = 0, livee = 0; // bind one pair in one order - jQuery('span#liveSpan1 a').live('click', function(){ lived++; return false; }); - jQuery('span#liveSpan1').live('click', function(){ livee++; }); + jQuery("span#liveSpan1 a").live("click", function(){ lived++; return false; }); + jQuery("span#liveSpan1").live("click", function(){ livee++; }); - jQuery('span#liveSpan1 a').click(); + jQuery("span#liveSpan1 a").click(); equals( lived, 1, "Verify that only one first handler occurred." ); equals( livee, 0, "Verify that second handler doesn't." ); // and one pair in inverse - jQuery('span#liveSpan2').live('click', function(){ livee++; }); - jQuery('span#liveSpan2 a').live('click', function(){ lived++; return false; }); + jQuery("span#liveSpan2").live("click", function(){ livee++; }); + jQuery("span#liveSpan2 a").live("click", function(){ lived++; return false; }); lived = 0; livee = 0; - jQuery('span#liveSpan2 a').click(); + jQuery("span#liveSpan2 a").click(); equals( lived, 1, "Verify that only one first handler occurred." ); equals( livee, 0, "Verify that second handler doesn't." ); @@ -1314,15 +1314,15 @@ test(".live()/.die()", function() { jQuery("span#liveSpan2").die("click"); // Test this, target and currentTarget are correct - jQuery('span#liveSpan1').live('click', function(e){ - equals( this.id, 'liveSpan1', 'Check the this within a live handler' ); - equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a live handler' ); - equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a live handler' ); + jQuery("span#liveSpan1").live("click", function(e){ + equals( this.id, "liveSpan1", "Check the this within a live handler" ); + equals( e.currentTarget.id, "liveSpan1", "Check the event.currentTarget within a live handler" ); + equals( e.target.nodeName.toUpperCase(), "A", "Check the event.target within a live handler" ); }); - jQuery('span#liveSpan1 a').click(); + jQuery("span#liveSpan1 a").click(); - jQuery('span#liveSpan1').die('click'); + jQuery("span#liveSpan1").die("click"); // Work with deep selectors livee = 0; @@ -1705,12 +1705,12 @@ test(".delegate()/.undelegate()", function() { jQuery("#body").undelegate("div", "submit"); // Test binding with a different context - var clicked = 0, container = jQuery('#main')[0]; + var clicked = 0, container = jQuery("#main")[0]; jQuery("#main").delegate("#foo", "click", function(e){ clicked++; }); - jQuery("div").trigger('click'); - jQuery("#foo").trigger('click'); - jQuery("#main").trigger('click'); - jQuery("body").trigger('click'); + jQuery("div").trigger("click"); + jQuery("#foo").trigger("click"); + jQuery("#main").trigger("click"); + jQuery("body").trigger("click"); equals( clicked, 2, "delegate with a context" ); // Make sure the event is actually stored on the context @@ -1718,7 +1718,7 @@ test(".delegate()/.undelegate()", function() { // Test unbinding with a different context jQuery("#main").undelegate("#foo", "click"); - jQuery("#foo").trigger('click'); + jQuery("#foo").trigger("click"); equals( clicked, 2, "undelegate with a context"); // Test binding with event data @@ -1804,9 +1804,9 @@ test(".delegate()/.undelegate()", function() { // Make sure we don't loose the target by DOM modifications // after the bubble already reached the liveHandler - var livec = 0, elemDiv = jQuery("#nothiddendivchild").html('').get(0); + var livec = 0, elemDiv = jQuery("#nothiddendivchild").html("").get(0); - jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ jQuery("#nothiddendivchild").html(''); }); + jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ jQuery("#nothiddendivchild").html(""); }); jQuery("#body").delegate("#nothiddendivchild", "click", function(e){ if(e.target) {livec++;} }); jQuery("#nothiddendiv span").click(); @@ -1821,20 +1821,20 @@ test(".delegate()/.undelegate()", function() { var lived = 0, livee = 0; // bind one pair in one order - jQuery("#body").delegate('span#liveSpan1 a', 'click', function(){ lived++; return false; }); - jQuery("#body").delegate('span#liveSpan1', 'click', function(){ livee++; }); + jQuery("#body").delegate("span#liveSpan1 a", "click", function(){ lived++; return false; }); + jQuery("#body").delegate("span#liveSpan1", "click", function(){ livee++; }); - jQuery('span#liveSpan1 a').click(); + jQuery("span#liveSpan1 a").click(); equals( lived, 1, "Verify that only one first handler occurred." ); equals( livee, 0, "Verify that second handler doesn't." ); // and one pair in inverse - jQuery("#body").delegate('span#liveSpan2', 'click', function(){ livee++; }); - jQuery("#body").delegate('span#liveSpan2 a', 'click', function(){ lived++; return false; }); + jQuery("#body").delegate("span#liveSpan2", "click", function(){ livee++; }); + jQuery("#body").delegate("span#liveSpan2 a", "click", function(){ lived++; return false; }); lived = 0; livee = 0; - jQuery('span#liveSpan2 a').click(); + jQuery("span#liveSpan2 a").click(); equals( lived, 1, "Verify that only one first handler occurred." ); equals( livee, 0, "Verify that second handler doesn't." ); @@ -1842,15 +1842,15 @@ test(".delegate()/.undelegate()", function() { jQuery("#body").undelegate("click"); // Test this, target and currentTarget are correct - jQuery("#body").delegate('span#liveSpan1', 'click', function(e){ - equals( this.id, 'liveSpan1', 'Check the this within a delegate handler' ); - equals( e.currentTarget.id, 'liveSpan1', 'Check the event.currentTarget within a delegate handler' ); - equals( e.target.nodeName.toUpperCase(), 'A', 'Check the event.target within a delegate handler' ); + jQuery("#body").delegate("span#liveSpan1", "click", function(e){ + equals( this.id, "liveSpan1", "Check the this within a delegate handler" ); + equals( e.currentTarget.id, "liveSpan1", "Check the event.currentTarget within a delegate handler" ); + equals( e.target.nodeName.toUpperCase(), "A", "Check the event.target within a delegate handler" ); }); - jQuery('span#liveSpan1 a').click(); + jQuery("span#liveSpan1 a").click(); - jQuery("#body").undelegate('span#liveSpan1', 'click'); + jQuery("#body").undelegate("span#liveSpan1", "click"); // Work with deep selectors livee = 0; @@ -2027,11 +2027,11 @@ test("Non DOM element events", function() { var o = {}; - jQuery(o).bind('nonelementobj', function(e) { + jQuery(o).bind("nonelementobj", function(e) { ok( true, "Event on non-DOM object triggered" ); }); - jQuery(o).trigger('nonelementobj'); + jQuery(o).trigger("nonelementobj"); }); test("window resize", function() { @@ -2049,7 +2049,7 @@ test("window resize", function() { test("focusin bubbles", function() { expect(5); - var input = jQuery( '' ).prependTo( "body" ), + var input = jQuery( "" ).prependTo( "body" ), order = 0; jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){ diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index e972a479..64265c9b 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -9,7 +9,7 @@ var functionReturningObj = function(value) { return (function() { return value; test("text()", function() { expect(2); var expected = "This link has class=\"blog\": Simon Willison's Weblog"; - equals( jQuery('#sap').text(), expected, 'Check for merged text of more then one element.' ); + equals( jQuery("#sap").text(), expected, "Check for merged text of more then one element." ); // Check serialization of text values equals( jQuery(document.createTextNode("foo")).text(), "foo", "Text node was retreived from .text()." ); @@ -43,34 +43,34 @@ test("text(Function) with incoming value", function() { var old = "This link has class=\"blog\": Simon Willison's Weblog"; - jQuery('#sap').text(function(i, val) { + jQuery("#sap").text(function(i, val) { equals( val, old, "Make sure the incoming value is correct." ); return "foobar"; }); - equals( jQuery("#sap").text(), "foobar", 'Check for merged text of more then one element.' ); + equals( jQuery("#sap").text(), "foobar", "Check for merged text of more then one element." ); QUnit.reset(); }); var testWrap = function(val) { expect(19); - var defaultText = 'Try them out:' - var result = jQuery('#first').wrap(val( '