X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fdata.js;h=0d75bc4440b6604aaf0fa159857446e835577709;hb=9e06903a99caf5619d0db858ed3d24f0e6ee15db;hp=fd03c54fab8f25bbc1f935b75975aab8bb5cfc7e;hpb=f6a0bf6816f4e2e67382b1b13fdd3ff2ea4b22f8;p=jquery.git diff --git a/test/unit/data.js b/test/unit/data.js index fd03c54..0d75bc4 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,12 +24,15 @@ test("expando", function(){ }); test("jQuery.data", function() { - expect(8); - var div = jQuery("#foo")[0]; - equals( jQuery.data(div, "test"), undefined, "Check for no data exists" ); + expect(9); + var div = document.createElement("div"); + + ok( jQuery.data(div, "test") === undefined, "Check for no data exists" ); jQuery.data(div, "test", "success"); equals( jQuery.data(div, "test"), "success", "Check for added data" ); + + ok( jQuery.data(div, "notexist") === undefined, "Check for no data exists" ); var data = jQuery.data(div); same( data, { "test": "success" }, "Return complete data set" ); @@ -58,18 +60,25 @@ test(".data()", function() { }) test(".data(String) and .data(String, Object)", function() { - expect(22); - var div = jQuery("#foo"); - equals( div.data("test"), undefined, "Check for no data exists" ); + expect(23); + var div = jQuery("
"); + + ok( div.data("test") === undefined, "Check for no data exists" ); + div.data("test", "success"); equals( div.data("test"), "success", "Check for added data" ); + div.data("test", "overwritten"); equals( div.data("test"), "overwritten", "Check for overwritten data" ); + div.data("test", undefined); equals( div.data("test"), "overwritten", "Check that data wasn't removed"); + div.data("test", null); ok( div.data("test") === null, "Check for null data"); + ok( div.data("notexist") === undefined, "Check for no data exists" ); + div.data("test", "overwritten"); var hits = {test:0}, gets = {test:0};