Skip to content

Commit d6f2f43

Browse files
committed
Fixing the busted unit/core tests.
- Clear the namespace property name cache if the namespace is changed.
1 parent b198f57 commit d6f2f43

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/unit/core/core.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,46 @@
3535
});
3636
});
3737

38+
function clearNSNormalizeDictionary()
39+
{
40+
var dict = $.mobile.nsNormalizeDict;
41+
for ( var prop in dict ) {
42+
delete dict[ prop ];
43+
}
44+
}
45+
3846
test( "$.mobile.nsNormalize works properly with namespace defined (test default)", function(){
47+
// Start with a fresh namespace property cache, just in case
48+
// the previous test mucked with namespaces.
49+
clearNSNormalizeDictionary();
50+
3951
equal($.mobile.nsNormalize("foo"), "nstestFoo", "appends ns and initcaps");
4052
equal($.mobile.nsNormalize("fooBar"), "nstestFooBar", "leaves capped strings intact");
4153
equal($.mobile.nsNormalize("foo-bar"), "nstestFooBar", "changes dashed strings");
4254
equal($.mobile.nsNormalize("foo-bar-bak"), "nstestFooBarBak", "changes multiple dashed strings");
55+
56+
// Reset the namespace property cache for the next test.
57+
clearNSNormalizeDictionary();
4358
});
4459

4560
test( "$.mobile.nsNormalize works properly with an empty namespace", function(){
4661
var realNs = $.mobile.ns;
4762

4863
$.mobile.ns = "";
4964

65+
// Start with a fresh namespace property cache, just in case
66+
// the previous test mucked with namespaces.
67+
clearNSNormalizeDictionary();
68+
5069
equal($.mobile.nsNormalize("foo"), "foo", "leaves uncapped and undashed");
5170
equal($.mobile.nsNormalize("fooBar"), "fooBar", "leaves capped strings intact");
5271
equal($.mobile.nsNormalize("foo-bar"), "fooBar", "changes dashed strings");
5372
equal($.mobile.nsNormalize("foo-bar-bak"), "fooBarBak", "changes multiple dashed strings");
5473

5574
$.mobile.ns = realNs;
75+
76+
// Reset the namespace property cache for the next test.
77+
clearNSNormalizeDictionary();
5678
});
5779

5880
//data tests

0 commit comments

Comments
 (0)