X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=71b124637f7b4737f7b341dbf9027a79e49990df;hb=cf78e396db1b986360c32fb0ca071a0fb90da064;hp=eba9ce5559d071be0debfeb2314e9e3965a1a4cf;hpb=9e48649729a5d4cd9ce52bcba067ba33a562cb4b;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index eba9ce5..71b1246 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -1140,24 +1140,30 @@ test("jQuery.extend(Object, Object)", function() { }); test("val()", function() { - expect(4); + expect(3); equals( jQuery("#text1").val(), "Test", "Check for value of input element" ); - equals( !jQuery("#text1").val(), "", "Check for value of input element" ); // ticket #1714 this caused a JS error in IE equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" ); ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" ); }); -test("val(String)", function() { - expect(4); +test("val(String/Number)", function() { + expect(6); document.getElementById('text1').value = "bla"; equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" ); + jQuery("#text1").val('test'); - ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" ); + equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" ); + + jQuery("#text1").val(67); + equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" ); jQuery("#select1").val("3"); equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" ); + jQuery("#select1").val(2); + equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" ); + // using contents will get comments regular, text, and comment nodes var j = jQuery("#nonnodes").contents(); j.val("asdf"); @@ -1168,7 +1174,7 @@ test("val(String)", function() { var scriptorder = 0; test("html(String)", function() { - expect(11); + expect(13); var div = jQuery("#main > div"); div.html("test"); var pass = true; @@ -1190,6 +1196,10 @@ test("html(String)", function() { jQuery("#main select").html(""); equals( jQuery("#main select").val(), "O2", "Selected option correct" ); + var $div = jQuery('
'); + equals( $div.html( 5 ).html(), '5', 'Setting a number as html' ); + equals( $div.html( 0 ).html(), '0', 'Setting a zero as html' ); + stop(); jQuery("#main").html(''); @@ -1565,13 +1575,18 @@ test("empty()", function() { }); test("slice()", function() { - expect(5); - isSet( jQuery("#ap a").slice(1,2), q("groups"), "slice(1,2)" ); - isSet( jQuery("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" ); - isSet( jQuery("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" ); - isSet( jQuery("#ap a").slice(-1), q("mark"), "slice(-1)" ); + expect(6); + + var $links = jQuery("#ap a"); + + isSet( $links.slice(1,2), q("groups"), "slice(1,2)" ); + isSet( $links.slice(1), q("groups", "anchor1", "mark"), "slice(1)" ); + isSet( $links.slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" ); + isSet( $links.slice(-1), q("mark"), "slice(-1)" ); - isSet( jQuery("#ap a").eq(1), q("groups"), "eq(1)" ); + isSet( $links.eq(1), q("groups"), "eq(1)" ); + + isSet( $links.eq('2'), q("anchor1"), "eq('2')" ); }); test("map()", function() {