X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=85b421d5a628671ff0bd8ae52e6f1edd976345ca;hb=8e53f7b5d6716e60d8c8ea7e167f2b187aae9d89;hp=d50997b2ccb16303944bf988b7413531abd8e96f;hpb=230614b4df313493813d688b63ab68f3812a0030;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index d50997b..85b421d 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -12,7 +12,7 @@ test("Basic requirements", function() { }); test("jQuery()", function() { - expect(22); + expect(23); // Basic constructor's behavior @@ -63,9 +63,12 @@ test("jQuery()", function() { equals( jQuery(document.body).get(0), jQuery('body').get(0), "Test passing an html node to the factory" ); + var exec = false; + var elem = jQuery("
", { width: 10, css: { paddingLeft:1, paddingRight:1 }, + click: function(){ ok(exec, "Click executed."); }, text: "test", "class": "test2", id: "test3" @@ -78,6 +81,9 @@ test("jQuery()", function() { equals( elem[0].firstChild.nodeValue, "test", 'jQuery quick setter text'); equals( elem[0].className, "test2", 'jQuery() quick setter class'); equals( elem[0].id, "test3", 'jQuery() quick setter id'); + + exec = true; + elem.click(); }); test("selector state", function() { @@ -643,7 +649,7 @@ test("jQuery.merge()", function() { }); test("jQuery.extend(Object, Object)", function() { - expect(25); + expect(27); var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }, options = { xnumber2: 1, xstring2: "x", xxx: "newstring" }, @@ -653,7 +659,9 @@ test("jQuery.extend(Object, Object)", function() { deep1copy = { foo: { bar: true } }, deep2 = { foo: { baz: true }, foo2: document }, deep2copy = { foo: { baz: true }, foo2: document }, - deepmerged = { foo: { bar: true, baz: true }, foo2: document }; + deepmerged = { foo: { bar: true, baz: true }, foo2: document }, + arr = [1, 2, 3], + nestedarray = { arr: arr }; jQuery.extend(settings, options); same( settings, merged, "Check if extended: settings must be extended" ); @@ -668,6 +676,9 @@ test("jQuery.extend(Object, Object)", function() { same( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" ); equals( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" ); + ok( jQuery.extend(true, [], arr) !== arr, "Deep extend of array must clone array" ); + ok( jQuery.extend(true, {}, nestedarray).arr !== arr, "Deep extend of object must clone child array" ); + var empty = {}; var optionsWithLength = { foo: { length: -1 } }; jQuery.extend(true, empty, optionsWithLength);