Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1300 from lzhan/comexecute
Browse files Browse the repository at this point in the history
fix issue #1280 Composite.execute cannot be called multiple times in the...
  • Loading branch information
lzhan committed Dec 18, 2013
2 parents af0bb62 + 71c0b0b commit 739aee5
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 17 deletions.
2 changes: 2 additions & 0 deletions HISTORY.md
Expand Up @@ -13,6 +13,8 @@ Features
Bug Fixes
---------

* Issue #1280: Composite.execute cannot be called multiple times in the same mojit

Acknowledgements
----------------

Expand Down
5 changes: 4 additions & 1 deletion lib/app/addons/ac/composite.common.js
Expand Up @@ -198,7 +198,6 @@ callback({

this.queue.done(function (results) {
var i;

// HookSystem::StartBlock
Y.mojito.hooks.hook('addon', my.adapter.hook, 'end', my);
// HookSystem::EndBlock
Expand Down Expand Up @@ -226,6 +225,10 @@ callback({
ac.assets.mixAssets(meta.assets, cfg.assets);
}

this.queue = new Y.Parallel({
context: this
});

cb(content, meta);
});
},
Expand Down
111 changes: 95 additions & 16 deletions tests/unit/lib/app/addons/ac/test-composite.common.js
Expand Up @@ -12,9 +12,10 @@
/*
* Test suite for the composite.common.js file functionality.
*/
YUI().use('mojito-composite-addon', 'test', function(Y) {

YUI().use('mojito-composite-addon', 'test', "async-queue", function(Y) {
Y.AsyncQueue.defaults.timeout = -1;
var suite = new Y.Test.Suite("mojito-composite-addon tests"),
q = new Y.AsyncQueue(),
A = Y.Assert,
OA = Y.ObjectAssert;

Expand Down Expand Up @@ -100,22 +101,100 @@ YUI().use('mojito-composite-addon', 'test', function(Y) {
kid_b: { id: 'kid_b', type: 'kidb' }
}
},
exeCbCalled = false;

c.execute(config, function(data, meta) {
exeCbCalled = true;
A.isString(data.kid_a, "missing kid_a data");
A.isString(data.kid_b, "missing kid_b data");
A.areSame('kid_a__data', data.kid_a, "wrong kid_a data");
A.areSame('kid_b__data', data.kid_b, "wrong kid_b data");
A.isString(meta.kid_a, "missing kid_a meta");
A.isString(meta.kid_b, "missing kid_b meta");
A.areSame('kid_a__meta', meta.kid_a, "wrong kid_a meta");
A.areSame('kid_b__meta', meta.kid_b, "wrong kid_b meta");
config1 = {
children: {
kid_c: { id: 'kid_c', type: 'kidc' }
}
},
config2 = {
children: {
kid_d: { id: 'kid_d', type: 'kidd' }
}
},
config3 = {
children: {
kid_e: { id: 'kid_e', type: 'kide' }
}
},
exeCbCalled = false,
exeCbCalled1 = false,
exeCbCalled2 = false,
exeCbCalled3 = false;

q.add(function() {
c.execute(config3, function(data, meta) {
exeCbCalled3 = true;
A.isString(data.kid_e, "missing kid_e data");
A.areSame('kid_e__data', data.kid_e, "wrong kid_e data");
A.isString(meta.kid_e, "missing kid_e meta");
A.areSame('kid_e__meta', meta.kid_e, "wrong kid_e meta");
A.isUndefined(data.kid_a, "should not have info about kid_a");
A.isUndefined(meta.kid_a, "should not have info about kid_a");
A.isUndefined(data.kid_b, "should not have info about kid_b");
A.isUndefined(meta.kid_b, "should not have info about kid_b");
A.isUndefined(data.kid_c, "should not have info about kid_c");
A.isUndefined(meta.kid_c, "should not have info about kid_c");
A.isUndefined(data.kid_d, "should not have info about kid_d");
A.isUndefined(meta.kid_d, "should not have info about kid_d");
});
});

q.add(function() {
c.execute(config, function(data, meta) {
exeCbCalled = true;
A.isString(data.kid_a, "missing kid_a data");
A.isString(data.kid_b, "missing kid_b data");
A.areSame('kid_a__data', data.kid_a, "wrong kid_a data");
A.areSame('kid_b__data', data.kid_b, "wrong kid_b data");
A.isString(meta.kid_a, "missing kid_a meta");
A.isString(meta.kid_b, "missing kid_b meta");
A.areSame('kid_a__meta', meta.kid_a, "wrong kid_a meta");
A.areSame('kid_b__meta', meta.kid_b, "wrong kid_b meta");

c.execute(config1, function(data, meta) {
exeCbCalled1 = true;
A.isString(data.kid_c, "missing kid_c data");
A.areSame('kid_c__data', data.kid_c, "wrong kid_c data");
A.isString(meta.kid_c, "missing kid_c meta");
A.areSame('kid_c__meta', meta.kid_c, "wrong kid_c meta");
A.isUndefined(data.kid_a, "should not have info about kid_a");
A.isUndefined(meta.kid_a, "should not have info about kid_a");
A.isUndefined(data.kid_b, "should not have info about kid_b");
A.isUndefined(meta.kid_b, "should not have info about kid_b");
A.isUndefined(data.kid_d, "should not have info about kid_d");
A.isUndefined(meta.kid_d, "should not have info about kid_d");
A.isUndefined(data.kid_e, "should not have info about kid_e");
A.isUndefined(meta.kid_e, "should not have info about kid_e");
});

c.execute(config2, function(data, meta) {
exeCbCalled2 = true;
A.isString(data.kid_d, "missing kid_d data");
A.areSame('kid_d__data', data.kid_d, "wrong kid_d data");
A.isString(meta.kid_d, "missing kid_d meta");
A.areSame('kid_d__meta', meta.kid_d, "wrong kid_d meta");
A.isUndefined(data.kid_a, "should not have info about kid_a");
A.isUndefined(meta.kid_a, "should not have info about kid_a");
A.isUndefined(data.kid_b, "should not have info about kid_b");
A.isUndefined(meta.kid_b, "should not have info about kid_b");
A.isUndefined(data.kid_c, "should not have info about kid_c");
A.isUndefined(meta.kid_c, "should not have info about kid_c");
A.isUndefined(data.kid_e, "should not have info about kid_e");
A.isUndefined(meta.kid_e, "should not have info about kid_e");
});

A.isUndefined(data.kid_c, "should not have info about kid_c");
A.isUndefined(meta.kid_c, "should not have info about kid_c");
A.isUndefined(data.kid_d, "should not have info about kid_d");
A.isUndefined(meta.kid_d, "should not have info about kid_d");
A.isUndefined(data.kid_e, "should not have info about kid_e");
A.isUndefined(meta.kid_e, "should not have info about kid_e");
});
});
q.run();
A.isTrue(exeCbCalled, "execute callback never called");

A.isTrue(exeCbCalled1, "execute callback 1 never called");
A.isTrue(exeCbCalled2, "execute callback 2 never called");
A.isTrue(exeCbCalled3, "execute callback 3 never called");
},

'test templateData (new API)': function() {
Expand Down

0 comments on commit 739aee5

Please sign in to comment.