|
35 | 35 | }); |
36 | 36 | }); |
37 | 37 |
|
| 38 | + function clearNSNormalizeDictionary() |
| 39 | + { |
| 40 | + var dict = $.mobile.nsNormalizeDict; |
| 41 | + for ( var prop in dict ) { |
| 42 | + delete dict[ prop ]; |
| 43 | + } |
| 44 | + } |
| 45 | + |
38 | 46 | 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 | + |
39 | 51 | equal($.mobile.nsNormalize("foo"), "nstestFoo", "appends ns and initcaps"); |
40 | 52 | equal($.mobile.nsNormalize("fooBar"), "nstestFooBar", "leaves capped strings intact"); |
41 | 53 | equal($.mobile.nsNormalize("foo-bar"), "nstestFooBar", "changes dashed strings"); |
42 | 54 | equal($.mobile.nsNormalize("foo-bar-bak"), "nstestFooBarBak", "changes multiple dashed strings"); |
| 55 | + |
| 56 | + // Reset the namespace property cache for the next test. |
| 57 | + clearNSNormalizeDictionary(); |
43 | 58 | }); |
44 | 59 |
|
45 | 60 | test( "$.mobile.nsNormalize works properly with an empty namespace", function(){ |
46 | 61 | var realNs = $.mobile.ns; |
47 | 62 |
|
48 | 63 | $.mobile.ns = ""; |
49 | 64 |
|
| 65 | + // Start with a fresh namespace property cache, just in case |
| 66 | + // the previous test mucked with namespaces. |
| 67 | + clearNSNormalizeDictionary(); |
| 68 | + |
50 | 69 | equal($.mobile.nsNormalize("foo"), "foo", "leaves uncapped and undashed"); |
51 | 70 | equal($.mobile.nsNormalize("fooBar"), "fooBar", "leaves capped strings intact"); |
52 | 71 | equal($.mobile.nsNormalize("foo-bar"), "fooBar", "changes dashed strings"); |
53 | 72 | equal($.mobile.nsNormalize("foo-bar-bak"), "fooBarBak", "changes multiple dashed strings"); |
54 | 73 |
|
55 | 74 | $.mobile.ns = realNs; |
| 75 | + |
| 76 | + // Reset the namespace property cache for the next test. |
| 77 | + clearNSNormalizeDictionary(); |
56 | 78 | }); |
57 | 79 |
|
58 | 80 | //data tests |
|
0 commit comments