Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.dtl.tests.context"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.dtl.tests.context"] = true;
3
dojo.provide("dojox.dtl.tests.context");
4
 
5
dojo.require("dojox.dtl");
6
 
7
doh.register("dojox.dtl.context",
8
	[
9
		function test_context_creation(t){
10
			var context = new dojox.dtl.Context({ foo: "foo", bar: "bar" });
11
			t.is("foo", context.foo);
12
			t.is("bar", context.bar);
13
		},
14
		function test_context_push(t){
15
			var context = new dojox.dtl.Context({ foo: "foo", bar: "bar" });
16
			context.push();
17
			for(var key in context._dicts[0]){
18
				t.t(key == "foo" || key == "bar");
19
			}
20
		},
21
		function test_context_pop(t){
22
			var context = new dojox.dtl.Context({ foo: "foo", bar: "bar" });
23
			context.push();
24
			t.is("undefined", typeof context.foo);
25
			t.is("undefined", typeof context.bar);
26
			context.pop();
27
			t.is("foo", context.foo);
28
			t.is("bar", context.bar);
29
		},
30
		function test_context_overpop(t){
31
			var context = new dojox.dtl.Context();
32
			try{
33
				context.pop();
34
				t.t(false);
35
			}catch(e){
36
				t.is("pop() has been called more times than push() on the Context", e.message);
37
			}
38
		},
39
		function test_context_filter(t){
40
			var context = new dojox.dtl.Context({ foo: "one", bar: "two", baz: "three" });
41
			var filtered = context.filter("foo", "bar");
42
			t.is(filtered.foo, "one");
43
			t.is(filtered.bar, "two");
44
			t.f(filtered.baz);
45
 
46
			filtered = context.filter({ bar: true, baz: true });
47
			t.f(filtered.foo);
48
			t.is(filtered.bar, "two");
49
			t.is(filtered.baz, "three");
50
 
51
			filtered = context.filter(new dojox.dtl.Context({ foo: true, baz: true }));
52
			t.is(filtered.foo, "one");
53
			t.f(filtered.bar);
54
			t.is(filtered.baz, "three");
55
		},
56
		function test_context_extend(t){
57
			var context = new dojox.dtl.Context({ foo: "one" });
58
			var extended = context.extend({ bar: "two", baz: "three" });
59
			t.is(extended.foo, "one");
60
			t.is(extended.bar, "two");
61
			t.is(extended.baz, "three");
62
 
63
			extended = context.extend({ barr: "two", bazz: "three" });
64
			t.is(extended.foo, "one");
65
			t.f(extended.bar);
66
			t.f(extended.baz);
67
			t.is(extended.barr, "two");
68
			t.is(extended.bazz, "three");
69
 
70
			t.f(context.bar)
71
			t.f(context.baz);
72
			t.f(context.barr);
73
			t.f(context.bazz);
74
		}
75
	]
76
);
77
 
78
}