Debian Codegraph @

dojox/app/tests/doh/error.js

raw symbols SCIP
1 define(["doh", "dojox/app/main", "dojox/json/ref", "dojo/text!./error1.json", "dojo/text!./error2.json",
2 "dojo/text!./error3.json", "dojo/text!./error4.json", "dojo/text!./error5.json", "dojo/text!./errorLast.json", "dojo/topic"],
3 function(doh, Application, json, config1, config2, config3, config4, config5, configLast, topic){
4 doh.register("dojox.app.tests.doh.error", [
5 {
6 timeout: 4000,
7 name: "error1",
8 runTest: function(t){
9 var dohDeferred = new doh.Deferred();
10 // stack events that are pushed
11 var events = [];
12 this._topic = topic.subscribe("/app/status", function(evt){
13 events.push(evt);
14 });
15 Application(json.fromJson(config1));
16 // we need to check that before timeout we _never_ entered the START (2) state
17 setTimeout(dohDeferred.getTestCallback(function(){
18 t.assertEqual([1], events);
19 }), 3000);
20 return dohDeferred;
21 },
22 tearDown: function(){
23 this._topic.remove();
24 // maybe dojox/app should do that?
25 delete testApp;
26 }
27 },
28 {
29 timeout: 4000,
30 name: "error2",
31 runTest: function(t){
32 var dohDeferred = new doh.Deferred();
33 // stack events that are pushed
34 var events = [];
35 this._topic = topic.subscribe("/app/status", function(evt){
36 events.push(evt);
37 });
38 Application(json.fromJson(config2));
39 // we need to check that before timeout we _never_ entered the START (2) state
40 setTimeout(dohDeferred.getTestCallback(function(){
41 t.assertEqual([1], events);
42 }), 3000);
43 return dohDeferred;
44 },
45 tearDown: function(){
46 this._topic.remove();
47 // maybe dojox/app should do that?
48 delete testApp;
49 }
50 },
51 {
52 timeout: 4000,
53 name: "error3",
54 runTest: function(t){
55 var dohDeferred = new doh.Deferred();
56 // stack events that are pushed
57 var events = [];
58 this._topic = topic.subscribe("/app/status", function(evt){
59 events.push(evt);
60 });
61 Application(json.fromJson(config3));
62 // we need to check that before timeout we _never_ entered the START (2) state
63 setTimeout(dohDeferred.getTestCallback(function(){
64 t.assertEqual([1], events);
65 }), 3000);
66 return dohDeferred;
67 },
68 tearDown: function(){
69 this._topic.remove();
70 // maybe dojox/app should do that?
71 delete testApp;
72 }
73 },
74 {
75 timeout: 4000,
76 name: "error4",
77 runTest: function(t){
78 var dohDeferred = new doh.Deferred();
79 // stack events that are pushed
80 var events = [];
81 this._topic = topic.subscribe("/app/status", function(evt){
82 events.push(evt);
83 });
84 Application(json.fromJson(config4));
85 // we need to check that before timeout we _never_ entered the START (2) state
86 setTimeout(dohDeferred.getTestCallback(function(){
87 t.assertEqual([1], events);
88 }), 3000);
89 return dohDeferred;
90 },
91 tearDown: function(){
92 this._topic.remove();
93 // maybe dojox/app should do that?
94 delete testApp;
95 }
96 },
97 {
98 timeout: 4000,
99 name: "error5",
100 runTest: function(t){
101 var dohDeferred = new doh.Deferred();
102 // stack events that are pushed
103 var events = [];
104 var goterror = false;
105 this._topic = topic.subscribe("/app/status", function(evt){
106 events.push(evt);
107 });
108 require(["dojox/app/main"], function(Application){
109 require.on ? require.on("error", function(){
110 goterror = true;
111 }) : null;
112 Application(json.fromJson(config5));
113 // we need to check that before timeout we _never_ entered the START (2) state
114 // and we must check error has been thrown
115 setTimeout(dohDeferred.getTestCallback(function(){
116 t.assertEqual([1], events);
117 t.assertTrue(goterror);
118 }), 3000);
119 });
120 return dohDeferred;
121 },
122 tearDown: function(){
123 this._topic.remove();
124 // maybe dojox/app should do that?
125 delete testApp;
126 }
127 },
128 {
129 timeout: 4000,
130 name: "errorLast",
131 runTest: function(t){
132 var dohDeferred = new doh.Deferred();
133 // stack events that are pushed
134 var events = [];
135 this._topic = topic.subscribe("/app/status", function(evt){
136 events.push(evt);
137 });
138 // to workaround http://trac.dojotoolkit.org/ticket/16032
139 for(var p in require.waiting){
140 delete require.waiting[p];
141 }
142 require.execQ.length = 0;
143 require(["dojox/app/main"], function(Application){
144 Application(json.fromJson(configLast));
145 // we need to check that before timeout we _never_ entered the START (2) state
146 setTimeout(dohDeferred.getTestCallback(function(){
147 t.assertEqual([1], events);
148 }), 3000);
149 });
150 return dohDeferred;
151 },
152 tearDown: function(){
153 this._topic.remove();
154 for(var p in require.waiting){
155 delete require.waiting[p];
156 }
157 require.execQ.length = 0;
158 // maybe dojox/app should do that?
159 delete testApp;
160 }
161 }
162 ]);
163 });