aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dojox/collections/tests/Queue.js
blob: 5ac61bc408cf7327b27d7d06c1f69c5b0e6f7416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
if(!dojo._hasResource["dojox.collections.tests.Queue"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.collections.tests.Queue"] = true;
dojo.provide("dojox.collections.tests.Queue");
dojo.require("dojox.collections.Queue");

tests.register("dojox.collections.tests.Queue", [
	function testCtor(t){
		var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
		t.assertEqual(4, q.count);
	},
	function testClear(t){
		var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
		q.clear();
		t.assertEqual(0, q.count);
	},
	function testClone(t){
		var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
		var cloned=q.clone();
		t.assertEqual(q.count, cloned.count);
		t.assertEqual(q.toArray().join(), cloned.toArray().join());
	},
	function testContains(t){
		var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
		t.assertTrue(q.contains("bar"));
		t.assertFalse(q.contains("faz"));
	},
	function testGetIterator(t){
		var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
		var itr=q.getIterator();
		while(!itr.atEnd()){ itr.get(); }
		t.assertEqual("bull", itr.element);
	},
	function testPeek(t){
		var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
		t.assertEqual("foo", q.peek());
	},
	function testDequeue(t){
		var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
		t.assertEqual("foo", q.dequeue());
		t.assertEqual("bar,test,bull", q.toArray().join(","));
	},
	function testEnqueue(t){
		var q=new dojox.collections.Queue(["foo","bar","test","bull"]);
		q.enqueue("bull");
		t.assertEqual("bull", q.toArray().pop());
	}
]);

}