summaryrefslogtreecommitdiff
path: root/includes/js/dojo/tests/DeferredList.js
diff options
context:
space:
mode:
Diffstat (limited to 'includes/js/dojo/tests/DeferredList.js')
-rw-r--r--includes/js/dojo/tests/DeferredList.js206
1 files changed, 0 insertions, 206 deletions
diff --git a/includes/js/dojo/tests/DeferredList.js b/includes/js/dojo/tests/DeferredList.js
deleted file mode 100644
index 9353bfa..0000000
--- a/includes/js/dojo/tests/DeferredList.js
+++ /dev/null
@@ -1,206 +0,0 @@
-if(!dojo._hasResource["tests.DeferredList"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
-dojo._hasResource["tests.DeferredList"] = true;
-dojo.provide("tests.DeferredList");
-
-dojo.require("dojo.DeferredList");
-
-doh.register("tests.DeferredList",
- [
- function callback(t){
- var d1 = new dojo.Deferred();
- var d2 = new dojo.Deferred();
- var dl = new dojo.DeferredList([d1, d2]);
- var fired = false;
-
- dl.addCallback(function(res){
- doh.debug("debug from dojo.DeferredList callback");
- return res;
- });
- dl.addCallback(function(res){
- console.log("res: ", res, res.length);
- t.assertTrue(res.length == 2);
- t.assertTrue(res[0][0]);
- t.assertEqual(res[0][1], "foo");
- t.assertTrue(res[1][0]);
- t.assertEqual(res[1][1], "bar");
- fired = true;
- return res;
- });
- d1.callback("foo");
- d2.callback("bar");
- t.assertTrue(fired);
- },
-
- function errback(t){
- var d1 = new dojo.Deferred();
- var d2 = new dojo.Deferred();
- var dl = new dojo.DeferredList([d1, d2]);
- var fired = false;
- var e1 = new Error("foo");
- var e2 = new Error("bar");
-
- dl.addCallback(function(res){
- doh.debug("debug from dojo.DeferredList callback");
- return res;
- });
- dl.addCallback(function(res){
- t.assertTrue(res.length == 2);
- t.assertTrue(!res[0][0]);
-
- t.assertEqual(res[0][1], e1);
- t.assertTrue(!res[1][0]);
- t.assertEqual(res[1][1], e2);
- fired = true;
- return res;
- });
- d1.errback(e1);
- d2.errback(e2);
- t.assertTrue(fired);
- },
-
-
- function mixed(t){
- var d1 = new dojo.Deferred();
- var d2 = new dojo.Deferred();
- var dl = new dojo.DeferredList([d1, d2]);
- var fired = false;
- var e = new Error("foo");
-
- dl.addCallback(function(res){
- doh.debug("debug from dojo.DeferredList callback");
- return res;
- });
- dl.addCallback(function(res){
- t.assertTrue(res.length == 2);
- t.assertTrue(!res[0][0]);
-
- t.assertEqual(res[0][1], e);
- t.assertTrue(res[1][0]);
- t.assertEqual(res[1][1], "bar");
- fired = true;
- return res;
- });
- d1.errback(e);
- d2.callback("bar");
- t.assertTrue(fired);
- },
-
- function gather(t){
- var d1 = new dojo.Deferred();
- var d2 = new dojo.Deferred();
- var dl = dojo.DeferredList.prototype.gatherResults([d1, d2]);
- var fired = false;
- dl.addCallback(function(res){
- t.assertEqual(res[0], "foo");
- t.assertEqual(res[1], "bar");
- fired = true;
- return res;
- });
- d1.callback("foo");
- d2.callback("bar");
- t.assertTrue(fired);
- }
- ]
-);
-dojo.provide("tests.DeferredList");
-
-dojo.require("dojo.DeferredList");
-
-doh.register("tests.DeferredList",
- [
- function callback(t){
- var d1 = new dojo.Deferred();
- var d2 = new dojo.Deferred();
- var dl = new dojo.DeferredList([d1, d2]);
- var fired = false;
- dl.addCallback(function(res){
- doh.debug("debug from dojo.DeferredList callback");
- return res;
- });
- dl.addCallback(function(res){
- t.assertTrue(res.length == 2);
- t.assertTrue(res[0][0]);
- t.assertEqual(res[0][1], "foo");
- t.assertTrue(res[1][0]);
- t.assertEqual(res[1][1], "bar");
- fired = true;
- return res;
- });
- d1.callback("foo");
- d2.callback("bar");
- t.assertTrue(fired);
- },
-
- function errback(t){
- var d1 = new dojo.Deferred();
- var d2 = new dojo.Deferred();
- var dl = new dojo.DeferredList([d1, d2]);
- var fired = false;
- var e1 = new Error("foo");
- var e2 = new Error("bar");
-
- dl.addCallback(function(res){
- doh.debug("debug from dojo.DeferredList callback");
- return res;
- });
- dl.addCallback(function(res){
- t.assertTrue(res.length == 2);
- t.assertTrue(!res[0][0]);
-
- t.assertEqual(res[0][1], e1);
- t.assertTrue(!res[1][0]);
- t.assertEqual(res[1][1], e2);
- fired = true;
- return res;
- });
- d1.errback(e1);
- d2.errback(e2);
- t.assertTrue(fired);
- },
-
-
- function mixed(t){
- var d1 = new dojo.Deferred();
- var d2 = new dojo.Deferred();
- var dl = new dojo.DeferredList([d1, d2]);
- var fired = false;
- var e = new Error("foo");
-
- dl.addCallback(function(res){
- doh.debug("debug from dojo.DeferredList callback");
- return res;
- });
- dl.addCallback(function(res){
- t.assertTrue(res.length == 2);
- t.assertTrue(!res[0][0]);
-
- t.assertEqual(res[0][1], e);
- t.assertTrue(res[1][0]);
- t.assertEqual(res[1][1], "bar");
- fired = true;
- return res;
- });
- d1.errback(e);
- d2.callback("bar");
- t.assertTrue(fired);
- },
-
- function gather(t){
- var d1 = new dojo.Deferred();
- var d2 = new dojo.Deferred();
- var dl = dojo.DeferredList.prototype.gatherResults([d1, d2]);
- var fired = false;
- dl.addCallback(function(res){
- t.assertEqual(res[0], "foo");
- t.assertEqual(res[1], "bar");
- fired = true;
- return res;
- });
- d1.callback("foo");
- d2.callback("bar");
- t.assertTrue(fired);
- }
- ]
-);
-
-}