From d6f2f438b66db393a66085b1cfbc3c905682f53e Mon Sep 17 00:00:00 2001 From: "jblas@adobe.com" Date: Tue, 8 Nov 2011 13:05:51 -0800 Subject: [PATCH] Fixing the busted unit/core tests. - Clear the namespace property name cache if the namespace is changed. --- tests/unit/core/core.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index 06eb651b..3b0d825e 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -35,11 +35,26 @@ }); }); + function clearNSNormalizeDictionary() + { + var dict = $.mobile.nsNormalizeDict; + for ( var prop in dict ) { + delete dict[ prop ]; + } + } + test( "$.mobile.nsNormalize works properly with namespace defined (test default)", function(){ + // Start with a fresh namespace property cache, just in case + // the previous test mucked with namespaces. + clearNSNormalizeDictionary(); + equal($.mobile.nsNormalize("foo"), "nstestFoo", "appends ns and initcaps"); equal($.mobile.nsNormalize("fooBar"), "nstestFooBar", "leaves capped strings intact"); equal($.mobile.nsNormalize("foo-bar"), "nstestFooBar", "changes dashed strings"); equal($.mobile.nsNormalize("foo-bar-bak"), "nstestFooBarBak", "changes multiple dashed strings"); + + // Reset the namespace property cache for the next test. + clearNSNormalizeDictionary(); }); test( "$.mobile.nsNormalize works properly with an empty namespace", function(){ @@ -47,12 +62,19 @@ $.mobile.ns = ""; + // Start with a fresh namespace property cache, just in case + // the previous test mucked with namespaces. + clearNSNormalizeDictionary(); + equal($.mobile.nsNormalize("foo"), "foo", "leaves uncapped and undashed"); equal($.mobile.nsNormalize("fooBar"), "fooBar", "leaves capped strings intact"); equal($.mobile.nsNormalize("foo-bar"), "fooBar", "changes dashed strings"); equal($.mobile.nsNormalize("foo-bar-bak"), "fooBarBak", "changes multiple dashed strings"); $.mobile.ns = realNs; + + // Reset the namespace property cache for the next test. + clearNSNormalizeDictionary(); }); //data tests