Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["tests.AdapterRegistry"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["tests.AdapterRegistry"] = true;
3
dojo.provide("tests.AdapterRegistry");
4
dojo.require("dojo.AdapterRegistry");
5
 
6
doh.register("tests.AdapterRegistry",
7
	[
8
		function ctor(t){
9
			var taa = new dojo.AdapterRegistry();
10
			t.is(0, taa.pairs.length);
11
			t.f(taa.returnWrappers);
12
 
13
			var taa = new dojo.AdapterRegistry(true);
14
			t.t(taa.returnWrappers);
15
		},
16
 
17
		function register(t){
18
			var taa = new dojo.AdapterRegistry();
19
			taa.register("blah",
20
				function(str){ return str == "blah"; },
21
				function(){ return "blah"; }
22
			);
23
			t.is(1, taa.pairs.length);
24
			t.is("blah", taa.pairs[0][0]);
25
 
26
			taa.register("thinger");
27
			taa.register("prepend", null, null, true, true);
28
			t.is("prepend", taa.pairs[0][0]);
29
			t.t(taa.pairs[0][3]);
30
		},
31
 
32
		/*
33
		function match(t){
34
		},
35
		*/
36
 
37
		function noMatch(t){
38
			var taa = new dojo.AdapterRegistry();
39
			var threw = false;
40
			try{
41
				taa.match("blah");
42
			}catch(e){
43
				threw = true;
44
			}
45
			t.t(threw);
46
		},
47
 
48
		function returnWrappers(t){
49
			var taa = new dojo.AdapterRegistry();
50
			taa.register("blah",
51
				function(str){ return str == "blah"; },
52
				function(){ return "blah"; }
53
			);
54
			t.is("blah", taa.match("blah"));
55
 
56
			taa.returnWrappers = true;
57
			t.is("blah", taa.match("blah")());
58
		},
59
 
60
		function unregister(t){
61
			var taa = new dojo.AdapterRegistry();
62
			taa.register("blah",
63
				function(str){ return str == "blah"; },
64
				function(){ return "blah"; }
65
			);
66
			taa.register("thinger");
67
			taa.register("prepend", null, null, true, true);
68
			taa.unregister("prepend");
69
			t.is(2, taa.pairs.length);
70
			t.is("blah", taa.pairs[0][0]);
71
		}
72
	]
73
);
74
 
75
}