1
YUI.add('globalevents-tests', function(Y) {
3
var suite = new Y.Test.Suite('IO Global Events Tests');
5
suite.add(new Y.Test.Case({
6
name: 'Success flow test',
10
this.a1 = ['start', 'complete', 'success', 'end'];
12
this.start = function(id, a) {
15
this.complete = function(id, o, a) {
18
this.success = function(id, o, a) {
21
this.end = function(id, a) {
25
this.resolve = function() {
26
for (var i=0; i < 4; i++) {
27
Y.Assert.areSame(t.a1[i], t.a0[i]);
30
this.start = Y.on('io:start', t.start, t, 'start');
31
this.complete = Y.on('io:complete', t.complete, t, 'complete');
32
this.success = Y.on('io:success', t.success, t, 'success');
33
this.end = Y.on('io:end', t.end, t, 'end');
35
tearDown: function() {
37
this.complete.detach();
38
this.success.detach();
41
testSuccessFlow: function() {
43
this.wait(null, 1000);
47
suite.add(new Y.Test.Case({
48
name: 'Failure flow test',
52
this.a2 = ['start', 'complete', 'failure', 'end'];
54
this.start = function(id, a) {
57
this.complete = function(id, o, a) {
60
this.failure = function(id, o, a) {
63
this.end = function(id, a) {
67
this.resolve = function() {
68
for (var i=0; i < 4; i++) {
69
Y.Assert.areSame(t.a2[i], t.a0[i]);
72
this.start = Y.on('io:start', t.start, t, 'start');
73
this.complete = Y.on('io:complete', t.complete, t, 'complete');
74
this.failure = Y.on('io:failure', t.failure, t, 'failure');
75
this.end = Y.on('io:end', t.end, t, 'end');
77
tearDown: function() {
79
this.complete.detach();
80
this.failure.detach();
83
testFailureFlow: function() {
84
Y.io(Y.IO.URLS.http + '?a=404');
85
this.wait(null, 1000);
89
Y.Test.Runner.add(suite);