2150 |
mathias |
1 |
if(!dojo._hasResource["dojox.collections.tests.Dictionary"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dojox.collections.tests.Dictionary"] = true;
|
|
|
3 |
dojo.provide("dojox.collections.tests.Dictionary");
|
|
|
4 |
dojo.require("dojox.collections.Dictionary");
|
|
|
5 |
|
|
|
6 |
tests.register("dojox.collections.tests.Dictionary", [
|
|
|
7 |
function testCtor(t){
|
|
|
8 |
var d=new dojox.collections.Dictionary();
|
|
|
9 |
t.assertTrue(d instanceof dojox.collections.Dictionary);
|
|
|
10 |
},
|
|
|
11 |
function testAdd(t){
|
|
|
12 |
var d=new dojox.collections.Dictionary();
|
|
|
13 |
d.add("foo","bar");
|
|
|
14 |
t.assertEqual("bar", d.item("foo").valueOf());
|
|
|
15 |
},
|
|
|
16 |
function testClear(t){
|
|
|
17 |
var d=new dojox.collections.Dictionary();
|
|
|
18 |
d.add("foo","bar");
|
|
|
19 |
d.clear()
|
|
|
20 |
t.assertEqual(0, d.count);
|
|
|
21 |
},
|
|
|
22 |
function testClone(t){
|
|
|
23 |
var d=new dojox.collections.Dictionary();
|
|
|
24 |
d.add("baz","fab");
|
|
|
25 |
d.add("buck","shot");
|
|
|
26 |
d.add("apple","orange");
|
|
|
27 |
var d2 = d.clone();
|
|
|
28 |
t.assertTrue(d2.contains("baz"));
|
|
|
29 |
},
|
|
|
30 |
function testContains(t){
|
|
|
31 |
var d=new dojox.collections.Dictionary();
|
|
|
32 |
d.add("foo","bar");
|
|
|
33 |
d.add("baz","fab");
|
|
|
34 |
d.add("buck","shot");
|
|
|
35 |
d.add("apple","orange");
|
|
|
36 |
t.assertTrue(d.contains("baz"));
|
|
|
37 |
},
|
|
|
38 |
function testContainsKey(t){
|
|
|
39 |
var d=new dojox.collections.Dictionary();
|
|
|
40 |
d.add("foo","bar");
|
|
|
41 |
d.add("baz","fab");
|
|
|
42 |
d.add("buck","shot");
|
|
|
43 |
d.add("apple","orange");
|
|
|
44 |
t.assertTrue(d.containsKey("buck"));
|
|
|
45 |
},
|
|
|
46 |
function testContainsValue(t){
|
|
|
47 |
var d=new dojox.collections.Dictionary();
|
|
|
48 |
d.add("foo","bar");
|
|
|
49 |
d.add("baz","fab");
|
|
|
50 |
d.add("buck","shot");
|
|
|
51 |
d.add("apple","orange");
|
|
|
52 |
t.assertTrue(d.containsValue("shot"));
|
|
|
53 |
},
|
|
|
54 |
function testGetKeyList(t){
|
|
|
55 |
var d=new dojox.collections.Dictionary();
|
|
|
56 |
d.add("foo","bar");
|
|
|
57 |
d.add("baz","fab");
|
|
|
58 |
d.add("buck","shot");
|
|
|
59 |
d.add("apple","orange");
|
|
|
60 |
t.assertEqual("foo,baz,buck,apple", d.getKeyList().join(","));
|
|
|
61 |
},
|
|
|
62 |
function testGetValueList(t){
|
|
|
63 |
var d=new dojox.collections.Dictionary();
|
|
|
64 |
d.add("foo","bar");
|
|
|
65 |
d.add("baz","fab");
|
|
|
66 |
d.add("buck","shot");
|
|
|
67 |
d.add("apple","orange");
|
|
|
68 |
t.assertEqual("bar,fab,shot,orange", d.getValueList().join(","));
|
|
|
69 |
},
|
|
|
70 |
function testRemove(t){
|
|
|
71 |
var d=new dojox.collections.Dictionary();
|
|
|
72 |
d.add("foo","bar");
|
|
|
73 |
d.add("baz","fab");
|
|
|
74 |
d.add("buck","shot");
|
|
|
75 |
d.add("apple","orange");
|
|
|
76 |
d.remove("baz");
|
|
|
77 |
t.assertEqual(3, d.count);
|
|
|
78 |
t.assertEqual(undefined, d.item("baz"));
|
|
|
79 |
}
|
|
|
80 |
]);
|
|
|
81 |
|
|
|
82 |
}
|