| 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 |
|
| 11 |
var events = []; |
| 12 |
this._topic = topic.subscribe("/app/status", function(evt){ |
| 13 |
events.push(evt); |
| 14 |
}); |
| 15 |
Application(json.fromJson(config1)); |
| 16 |
|
| 17 |
setTimeout(dohDeferred.getTestCallback(function(){ |
| 18 |
t.assertEqual([1], events); |
| 19 |
}), 3000); |
| 20 |
return dohDeferred; |
| 21 |
}, |
| 22 |
tearDown: function(){ |
| 23 |
this._topic.remove(); |
| 24 |
|
| 25 |
delete testApp; |
| 26 |
} |
| 27 |
}, |
| 28 |
{ |
| 29 |
timeout: 4000, |
| 30 |
name: "error2", |
| 31 |
runTest: function(t){ |
| 32 |
var dohDeferred = new doh.Deferred(); |
| 33 |
|
| 34 |
var events = []; |
| 35 |
this._topic = topic.subscribe("/app/status", function(evt){ |
| 36 |
events.push(evt); |
| 37 |
}); |
| 38 |
Application(json.fromJson(config2)); |
| 39 |
|
| 40 |
setTimeout(dohDeferred.getTestCallback(function(){ |
| 41 |
t.assertEqual([1], events); |
| 42 |
}), 3000); |
| 43 |
return dohDeferred; |
| 44 |
}, |
| 45 |
tearDown: function(){ |
| 46 |
this._topic.remove(); |
| 47 |
|
| 48 |
delete testApp; |
| 49 |
} |
| 50 |
}, |
| 51 |
{ |
| 52 |
timeout: 4000, |
| 53 |
name: "error3", |
| 54 |
runTest: function(t){ |
| 55 |
var dohDeferred = new doh.Deferred(); |
| 56 |
|
| 57 |
var events = []; |
| 58 |
this._topic = topic.subscribe("/app/status", function(evt){ |
| 59 |
events.push(evt); |
| 60 |
}); |
| 61 |
Application(json.fromJson(config3)); |
| 62 |
|
| 63 |
setTimeout(dohDeferred.getTestCallback(function(){ |
| 64 |
t.assertEqual([1], events); |
| 65 |
}), 3000); |
| 66 |
return dohDeferred; |
| 67 |
}, |
| 68 |
tearDown: function(){ |
| 69 |
this._topic.remove(); |
| 70 |
|
| 71 |
delete testApp; |
| 72 |
} |
| 73 |
}, |
| 74 |
{ |
| 75 |
timeout: 4000, |
| 76 |
name: "error4", |
| 77 |
runTest: function(t){ |
| 78 |
var dohDeferred = new doh.Deferred(); |
| 79 |
|
| 80 |
var events = []; |
| 81 |
this._topic = topic.subscribe("/app/status", function(evt){ |
| 82 |
events.push(evt); |
| 83 |
}); |
| 84 |
Application(json.fromJson(config4)); |
| 85 |
|
| 86 |
setTimeout(dohDeferred.getTestCallback(function(){ |
| 87 |
t.assertEqual([1], events); |
| 88 |
}), 3000); |
| 89 |
return dohDeferred; |
| 90 |
}, |
| 91 |
tearDown: function(){ |
| 92 |
this._topic.remove(); |
| 93 |
|
| 94 |
delete testApp; |
| 95 |
} |
| 96 |
}, |
| 97 |
{ |
| 98 |
timeout: 4000, |
| 99 |
name: "error5", |
| 100 |
runTest: function(t){ |
| 101 |
var dohDeferred = new doh.Deferred(); |
| 102 |
|
| 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 |
|
| 114 |
|
| 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 |
|
| 125 |
delete testApp; |
| 126 |
} |
| 127 |
}, |
| 128 |
{ |
| 129 |
timeout: 4000, |
| 130 |
name: "errorLast", |
| 131 |
runTest: function(t){ |
| 132 |
var dohDeferred = new doh.Deferred(); |
| 133 |
|
| 134 |
var events = []; |
| 135 |
this._topic = topic.subscribe("/app/status", function(evt){ |
| 136 |
events.push(evt); |
| 137 |
}); |
| 138 |
|
| 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 |
|
| 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 |
|
| 159 |
delete testApp; |
| 160 |
} |
| 161 |
} |
| 162 |
]); |
| 163 |
}); |