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