summaryrefslogtreecommitdiff
path: root/includes/js/dojo/tests/_base.js
blob: 7bc530108b25c1d0cd2f51e8a635cc8df718a937 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
if(!dojo._hasResource["tests._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["tests._base"] = true;
var testGlobal = this;
try{
	dojo.provide("tests._base");
	testGlobal = dojo.global;
}catch(e){ }

// the test suite for the bootstrap. Requires hostenv and other base tests at
// the end

if(doh.selfTest){

	doh.register("doh.smokeTest", 
		[
			function sanityCheckHarness(t){
				// sanity checks
				t.assertTrue(true);
				t.assertFalse(false);
				t.assertFalse(0);
				t.assertFalse(null);
				var tObj = { w00t: false, blarg: true };
				t.assertEqual(
					["thinger", "blah", tObj], 
					["thinger", "blah", tObj]
				);
				t.assertEqual(tObj, tObj);
			},
			/*
			// uncomment to tests exception handling
			function sanityCheckassertTrue(t){
				// should throw an error
				t.assertTrue(false);
			},
			function sanityCheckassertFalse(t){
				// should throw an error
				t.assertFalse(true);
			},
			function sanityCheckassertEqual(t){
				// should throw an error
				t.assertEqual("foo", "bar");
			},
			*/
			{
				name: "eqTest",
				// smoke test the fixture system
				setUp: function(t){
					this.foo = "blah";
				},
				runTest: function(t){
					t.assertEqual("blah", this.foo);
				},
				tearDown: function(t){
				}
			}
		]
	);

	if(testGlobal["dojo"]){
		doh.register("tests._base", 
			[
				function dojoIsAvailable(t){
					t.assertTrue(testGlobal["dojo"]);
				}
			]
		);
	}

	if(testGlobal["setTimeout"]){
		// a stone-stupid async test
		doh.register("tests.async", 
			[
				{
					name: "deferredSuccess",
					runTest: function(t){
						var d = new doh.Deferred();
						setTimeout(d.getTestCallback(function(){
							t.assertTrue(true);
							t.assertFalse(false);
						}), 50);
						return d;
					}
				},
				{
					name: "deferredFailure",
					runTest: function(t){
						var d = new doh.Deferred();
						setTimeout(function(){
							d.errback(new Error("hrm..."));
						}, 50);
						return d;
					}
				},
				{
					name: "timeoutFailure",
					timeout: 50,
					runTest: function(t){
						// timeout of 50
						var d = new doh.Deferred();
						setTimeout(function(){
							d.callback(true);
						}, 100);
						return d;
					}
				}
			]
		);
	}
}

try{
	// go grab the others
	dojo.require("tests._base._loader.bootstrap");
	dojo.require("tests._base._loader.loader");
	dojo.platformRequire({
		browser: ["tests._base._loader.hostenv_browser"],
		rhino: ["tests._base._loader.hostenv_rhino"],
		spidermonkey: ["tests._base._loader.hostenv_spidermonkey"]
	});
	dojo.require("tests._base.array");
	dojo.require("tests._base.Color");
	dojo.require("tests._base.lang");
	dojo.require("tests._base.declare");
	dojo.require("tests._base.connect");
	dojo.require("tests._base.Deferred");
	dojo.require("tests._base.json");
	// FIXME: add test includes for the rest of the Dojo Base groups here
	dojo.requireIf(dojo.isBrowser, "tests._base.html");
	dojo.requireIf(dojo.isBrowser, "tests._base.fx");
	dojo.requireIf(dojo.isBrowser, "tests._base.query");
	dojo.requireIf(dojo.isBrowser, "tests._base.xhr");
}catch(e){
	doh.debug(e);
}

}