Replace usage of the removed global reset() method with QUnit.reset().
[jquery.git] / test / unit / core.js
index 4576ab8..5d6b9fe 100644 (file)
@@ -201,14 +201,20 @@ test("noConflict", function() {
 });
 
 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() {
@@ -265,7 +271,7 @@ 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();
 });
 
@@ -392,7 +398,7 @@ test("isXMLDoc - XML", function() {
 test("jQuery('html')", function() {
        expect(15);
 
-       reset();
+       QUnit.reset();
        jQuery.foo = false;
        var s = jQuery("<script>jQuery.foo='test';</script>")[0];
        ok( s, "Creating a script" );
@@ -408,7 +414,7 @@ test("jQuery('html')", function() {
        equals( div.childNodes[1].nodeType, 1, "Paragraph." );
        equals( div.childNodes[1].firstChild.nodeType, 3, "Paragraph text." );
 
-       reset();
+       QUnit.reset();
        ok( jQuery("<link rel='stylesheet'/>")[0], "Creating a link" );
 
        ok( !jQuery("<script/>")[0].parentNode, "Create a script" );
@@ -807,7 +813,7 @@ test("jQuery.proxy", function(){
 });
 
 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." );
@@ -815,6 +821,8 @@ test("jQuery.parseJSON", function(){
        
        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}");
@@ -829,4 +837,4 @@ test("jQuery.parseJSON", function(){
        } catch( e ) {
                ok( true, "Test malformed JSON string." );
        }
-});
\ No newline at end of file
+});