Commit 41eba17a authored by Tristan Cavelier's avatar Tristan Cavelier

notifications are not propagated to parents fixed

parent fdaaddad
......@@ -203,6 +203,11 @@ function handleThenable(promise, value) {
then = value.then;
if (isFunction(then)) {
if (isFunction(value.on)) {
value.on('promise:notified', function (event) {
notify(promise, event.detail);
});
}
promise.on('promise:cancelled', function(event) {
if (isFunction(value.cancel)) {
value.cancel();
......
......@@ -236,6 +236,31 @@ describe("RSVP extensions", function() {
});
});
it('notify should propagate to parent `then`', function (done) {
var i = 0, responses = [];
new RSVP.Promise(function (resolve) {
resolve();
}).then(function () {
return new RSVP.Promise(function (resolve, reject, notify) {
notify(1);
notify(2);
resolve(3);
});
}).then(function (answer) {
responses.push(answer);
}, null, function (notification) {
responses.push(notification);
});
setTimeout(function () {
assert(responses[0] === 1, "Notified once");
assert(responses[1] === 2, "Notified twice");
assert(responses[2] === 3, "Fulfilled after notifications");
done();
}, 50);
});
describe('assimilation', function() {
it('should assimilate if `resolve` is called with a fulfilled promise', function(done) {
var originalPromise = new RSVP.Promise(function(resolve) { resolve('original value'); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment