X-Git-Url: http://git.asbjorn.biz/?p=jquery.git;a=blobdiff_plain;f=test%2Funit%2Fdata.js;h=c867fb5465d473b4a08f93981ffab453a9119fe0;hp=b0c9f3f82b018920fc1941a4fe1675ad68fca577;hb=8a5df39045292397a06d08b4fab2ad29819b5d44;hpb=a7d0b0b9e887782bf1ed795152a845da87729c52 diff --git a/test/unit/data.js b/test/unit/data.js index b0c9f3f..c867fb5 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -184,14 +184,17 @@ test(".data(String) and .data(String, Object)", function() { }); test("data-* attributes", function() { - expect(27); + expect(33); var div = jQuery("
"), - child = jQuery("
"); + child = jQuery("
"); equals( div.data("attr"), undefined, "Check for non-existing data-attr attribute" ); div.attr("data-attr", "exists"); equals( div.data("attr"), "exists", "Check for existing data-attr attribute" ); + + div.attr("data-attr", "exists2"); + equals( div.data("attr"), "exists", "Check that updates to data- don't update .data()" ); div.data("attr", "internal").attr("data-attr", "external"); equals( div.data("attr"), "internal", "Check for .data('attr') precedence (internal > external data-* attribute)" ); @@ -205,6 +208,22 @@ test("data-* attributes", function() { child.data("ignored", "cache"); equals( child.data("ignored"), "cache", "Cached data used before DOM data-* fallback"); + var obj = child.data(), check = [ "myobj", "ignored", "other" ], num = 0; + + for ( var i = 0, l = check.length; i < l; i++ ) { + ok( obj[ check[i] ], "Make sure data- property exists when calling data-." ); + } + + for ( var prop in obj ) { + num++; + } + + equals( num, check.length, "Make sure that the right number of properties came through." ); + + child.attr("data-other", "newvalue"); + + equals( child.data("other"), "test", "Make sure value was pulled in properly from a .data()." ); + child .attr("data-true", "true") .attr("data-false", "false")