]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojo/tests/_base/_loader/bootstrap.js
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojo / tests / _base / _loader / bootstrap.js
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                 {
15                         name: "getObject",
16                         setUp: function(){
17                                 //Set an object in global scope.
18                                 dojo.global.globalValue = {
19                                         color: "blue",
20                                         size: 20
21                                 };
22                                 
23                                 //Set up an object in a specific scope.
24                                 this.foo = {
25                                         bar: {
26                                                 color: "red",
27                                                 size: 100
28                                         }
29                                 };
30                         },
31                         runTest: function(t){
32                                 //Test for existing object using global as root path.
33                                 var globalVar = dojo.getObject("globalValue");
34                                 t.is("object", (typeof globalVar));
35                                 t.assertEqual("blue", globalVar.color);
36                                 t.assertEqual(20, globalVar.size);
37                                 t.assertEqual("blue", dojo.getObject("globalValue.color"));
38                                 
39                                 //Test for non-existent object using global as root path.
40                                 //Then create it.
41                                 t.assertFalse(dojo.getObject("something.thatisNew"));
42                                 t.assertTrue(typeof(dojo.getObject("something.thatisNew", true)) == "object");
43                                 
44                                 //Test for existing object using another object as root path.
45                                 var scopedVar = dojo.getObject("foo.bar", false, this);
46                                 t.assertTrue(typeof(scopedVar) == "object");
47                                 t.assertEqual("red", scopedVar.color);
48                                 t.assertEqual(100, scopedVar.size);
49                                 t.assertEqual("red", dojo.getObject("foo.bar.color", true, this));
50                                 
51                                 //Test for existing object using another object as root path.
52                                 //Then create it.
53                                 t.assertFalse(dojo.getObject("something.thatisNew", false, this));
54                                 t.assertTrue(typeof(dojo.getObject("something.thatisNew", true, this)) == "object");
55                         },
56                         tearDown: function(){
57                                 //Clean up global object that should not exist if
58                                 //the test is re-run.
59                                 try{
60                                         delete dojo.global.something;
61                                         delete this.something;
62                                 }catch(e){}
63                         }
64                 },
65                 
66                 {
67                         name: "exists",
68                         setUp: function(){
69                                 this.foo = {
70                                         bar: {}
71                                 };
72                         },
73                         runTest: function(t){
74                                 t.assertTrue(dojo.exists("foo.bar", this));
75                                 t.assertFalse(dojo.exists("foo.bar"));
76                         }
77                 },
78
79                 function evalWorks(t){
80                         t.assertTrue(dojo.eval("(true)"));
81                         t.assertFalse(dojo.eval("(false)"));
82                 }
83         ]
84 );
85
86 }