]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojo/tests/_base.js
Comment class stub
[eow] / static / dojo-release-1.1.1 / dojo / tests / _base.js
1 if(!dojo._hasResource["tests._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["tests._base"] = true;
3 var testGlobal = this;
4 try{
5         dojo.provide("tests._base");
6         testGlobal = dojo.global;
7 }catch(e){ }
8
9 // the test suite for the bootstrap. Requires hostenv and other base tests at
10 // the end
11
12 if(doh.selfTest){
13
14         doh.register("doh.smokeTest", 
15                 [
16                         function sanityCheckHarness(t){
17                                 // sanity checks
18                                 t.assertTrue(true);
19                                 t.assertFalse(false);
20                                 t.assertFalse(0);
21                                 t.assertFalse(null);
22                                 var tObj = { w00t: false, blarg: true };
23                                 t.assertEqual(
24                                         ["thinger", "blah", tObj], 
25                                         ["thinger", "blah", tObj]
26                                 );
27                                 t.assertEqual(tObj, tObj);
28                         },
29                         /*
30                         // uncomment to tests exception handling
31                         function sanityCheckassertTrue(t){
32                                 // should throw an error
33                                 t.assertTrue(false);
34                         },
35                         function sanityCheckassertFalse(t){
36                                 // should throw an error
37                                 t.assertFalse(true);
38                         },
39                         function sanityCheckassertEqual(t){
40                                 // should throw an error
41                                 t.assertEqual("foo", "bar");
42                         },
43                         */
44                         {
45                                 name: "eqTest",
46                                 // smoke test the fixture system
47                                 setUp: function(t){
48                                         this.foo = "blah";
49                                 },
50                                 runTest: function(t){
51                                         t.assertEqual("blah", this.foo);
52                                 },
53                                 tearDown: function(t){
54                                 }
55                         }
56                 ]
57         );
58
59         if(testGlobal["dojo"]){
60                 doh.register("tests._base", 
61                         [
62                                 function dojoIsAvailable(t){
63                                         t.assertTrue(testGlobal["dojo"]);
64                                 }
65                         ]
66                 );
67         }
68
69         if(testGlobal["setTimeout"]){
70                 // a stone-stupid async test
71                 doh.register("tests.async", 
72                         [
73                                 {
74                                         name: "deferredSuccess",
75                                         runTest: function(t){
76                                                 var d = new doh.Deferred();
77                                                 setTimeout(d.getTestCallback(function(){
78                                                         t.assertTrue(true);
79                                                         t.assertFalse(false);
80                                                 }), 50);
81                                                 return d;
82                                         }
83                                 },
84                                 {
85                                         name: "deferredFailure",
86                                         runTest: function(t){
87                                                 var d = new doh.Deferred();
88                                                 setTimeout(function(){
89                                                         d.errback(new Error("hrm..."));
90                                                 }, 50);
91                                                 return d;
92                                         }
93                                 },
94                                 {
95                                         name: "timeoutFailure",
96                                         timeout: 50,
97                                         runTest: function(t){
98                                                 // timeout of 50
99                                                 var d = new doh.Deferred();
100                                                 setTimeout(function(){
101                                                         d.callback(true);
102                                                 }, 100);
103                                                 return d;
104                                         }
105                                 }
106                         ]
107                 );
108         }
109 }
110
111 try{
112         // go grab the others
113         dojo.require("tests._base._loader.bootstrap");
114         dojo.require("tests._base._loader.loader");
115         dojo.platformRequire({
116                 browser: ["tests._base._loader.hostenv_browser"],
117                 rhino: ["tests._base._loader.hostenv_rhino"],
118                 spidermonkey: ["tests._base._loader.hostenv_spidermonkey"]
119         });
120         dojo.require("tests._base.array");
121         dojo.require("tests._base.Color");
122         dojo.require("tests._base.lang");
123         dojo.require("tests._base.declare");
124         dojo.require("tests._base.connect");
125         dojo.require("tests._base.Deferred");
126         dojo.require("tests._base.json");
127         // FIXME: add test includes for the rest of the Dojo Base groups here
128         dojo.requireIf(dojo.isBrowser, "tests._base.html");
129         dojo.requireIf(dojo.isBrowser, "tests._base.fx");
130         dojo.requireIf(dojo.isBrowser, "tests._base.query");
131         dojo.requireIf(dojo.isBrowser, "tests._base.xhr");
132 }catch(e){
133         doh.debug(e);
134 }
135
136 }