});
test("trim", function() {
- expect(4);
+ expect(9);
- var nbsp = String.fromCharCode(160);
+ var nbsp = String.fromCharCode(160);
- equals( jQuery.trim("hello "), "hello", "trailing space" );
- equals( jQuery.trim(" hello"), "hello", "leading space" );
- equals( jQuery.trim(" hello "), "hello", "space on both sides" );
- equals( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " );
+ equals( jQuery.trim("hello "), "hello", "trailing space" );
+ equals( jQuery.trim(" hello"), "hello", "leading space" );
+ equals( jQuery.trim(" hello "), "hello", "space on both sides" );
+ equals( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " );
+
+ equals( jQuery.trim(), "", "Nothing in." );
+ equals( jQuery.trim( undefined ), "", "Undefined" );
+ equals( jQuery.trim( null ), "", "Null" );
+ equals( jQuery.trim( 5 ), "5", "Number" );
+ equals( jQuery.trim( false ), "false", "Boolean" );
});
test("isPlainObject", function() {
var doc = iframe.contentDocument || iframe.contentWindow.document;
doc.open();
- doc.write("<body onload='window.top.iframeDone(Object);'>");
+ doc.write("<body onload='window.parent.iframeDone(Object);'>");
doc.close();
});
});
test("jQuery.parseJSON", function(){
- expect(7);
+ expect(8);
equals( jQuery.parseJSON(), null, "Nothing in, null out." );
equals( jQuery.parseJSON( null ), null, "Nothing in, null out." );
same( jQuery.parseJSON("{}"), {}, "Plain object parsing." );
same( jQuery.parseJSON('{"test":1}'), {"test":1}, "Plain object parsing." );
+
+ same( jQuery.parseJSON('\n{"test":1}'), {"test":1}, "Make sure leading whitespaces are handled." );
try {
jQuery.parseJSON("{a:1}");
} catch( e ) {
ok( true, "Test malformed JSON string." );
}
-});
\ No newline at end of file
+});