X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fdata.js;h=79b23c6936b884b3e2095b824602357d9d3ac2f3;hb=021b809acecc4e94613375b3182c86722470fe9b;hp=3916534c19a237e6b2f7b2f64d40a9b64b19824f;hpb=ebad701751689b773afe29d1e3c4532c7810d02a;p=jquery.git diff --git a/test/unit/data.js b/test/unit/data.js index 3916534..79b23c6 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -1,20 +1,19 @@ module("data"); test("expando", function(){ - expect(7); + expect(6); equals("expando" in jQuery, true, "jQuery is exposing the expando"); var obj = {}; jQuery.data(obj); - equals( jQuery.expando in obj, false, "jQuery.data did not add an expando to the object" ); - - jQuery.data(obj, true); - equals( jQuery.expando in obj, false, "jQuery.data did not add an expando to the object" ); - + equals( jQuery.expando in obj, true, "jQuery.data adds an expando to the object" ); + + obj = {}; jQuery.data(obj, 'test'); equals( jQuery.expando in obj, false, "jQuery.data did not add an expando to the object" ); - + + obj = {}; jQuery.data(obj, "foo", "bar"); equals( jQuery.expando in obj, true, "jQuery.data added an expando to the object" ); @@ -25,7 +24,7 @@ test("expando", function(){ }); test("jQuery.data", function() { - expect(6); + expect(8); var div = jQuery("#foo")[0]; equals( jQuery.data(div, "test"), undefined, "Check for no data exists" ); @@ -43,6 +42,10 @@ test("jQuery.data", function() { jQuery.data(div, "test", null); ok( jQuery.data(div, "test") === null, "Check for null data"); + + jQuery.data(div, { "test": "in", "test2": "in2" }); + equals( jQuery.data(div, "test"), "in", "Verify setting an object in data." ); + equals( jQuery.data(div, "test2"), "in2", "Verify setting an object in data." ); }); test(".data()", function() { @@ -114,6 +117,16 @@ test(".data(String) and .data(String, Object)", function() { $elem.removeData(); }); +test(".data(Object)", function() { + expect(2); + + var div = jQuery("
"); + + div.data({ "test": "in", "test2": "in2" }); + equals( div.data("test"), "in", "Verify setting an object in data." ); + equals( div.data("test2"), "in2", "Verify setting an object in data." ); +}); + test("jQuery.removeData", function() { expect(1); var div = jQuery("#foo")[0];