Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["tests._base._loader.bootstrap"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["tests._base._loader.bootstrap"] = true;
3
dojo.provide("tests._base._loader.bootstrap");
4
 
5
tests.register("tests._base._loader.bootstrap",
6
	[
7
 
8
		function hasConsole(t){
9
			t.assertTrue("console" in dojo.global);
10
			t.assertTrue("assert" in console);
11
			t.assertEqual("function", typeof console.assert);
12
		},
13
 
14
		function hasDjConfig(t){
15
			t.assertTrue("djConfig" in dojo.global);
16
		},
17
 
18
		{
19
			name: "getObject",
20
			setUp: function(){
21
				//Set an object in global scope.
22
				dojo.global.globalValue = {
23
					color: "blue",
24
					size: 20
25
				};
26
 
27
				//Set up an object in a specific scope.
28
				this.foo = {
29
					bar: {
30
						color: "red",
31
						size: 100
32
					}
33
				};
34
			},
35
			runTest: function(t){
36
				//Test for existing object using global as root path.
37
				var globalVar = dojo.getObject("globalValue");
38
				t.is("object", (typeof globalVar));
39
				t.assertEqual("blue", globalVar.color);
40
				t.assertEqual(20, globalVar.size);
41
				t.assertEqual("blue", dojo.getObject("globalValue.color"));
42
 
43
				//Test for non-existent object using global as root path.
44
				//Then create it.
45
				t.assertFalse(dojo.getObject("something.thatisNew"));
46
				t.assertTrue(typeof(dojo.getObject("something.thatisNew", true)) == "object");
47
 
48
				//Test for existing object using another object as root path.
49
				var scopedVar = dojo.getObject("foo.bar", false, this);
50
				t.assertTrue(typeof(scopedVar) == "object");
51
				t.assertEqual("red", scopedVar.color);
52
				t.assertEqual(100, scopedVar.size);
53
				t.assertEqual("red", dojo.getObject("foo.bar.color", true, this));
54
 
55
				//Test for existing object using another object as root path.
56
				//Then create it.
57
				t.assertFalse(dojo.getObject("something.thatisNew", false, this));
58
				t.assertTrue(typeof(dojo.getObject("something.thatisNew", true, this)) == "object");
59
			},
60
			tearDown: function(){
61
				//Clean up global object that should not exist if
62
				//the test is re-run.
63
				try{
64
					delete dojo.global.something;
65
					delete this.something;
66
				}catch(e){}
67
			}
68
		},
69
 
70
		{
71
			name: "exists",
72
			setUp: function(){
73
				this.foo = {
74
					bar: {}
75
				};
76
			},
77
			runTest: function(t){
78
				t.assertTrue(dojo.exists("foo.bar", this));
79
				t.assertFalse(dojo.exists("foo.bar"));
80
			}
81
		},
82
 
83
		function evalWorks(t){
84
			t.assertTrue(dojo.eval("(true)"));
85
			t.assertFalse(dojo.eval("(false)"));
86
		}
87
	]
88
);
89
 
90
}