Commit c4c6e9d6 authored by Stefan Penner's avatar Stefan Penner

Merge pull request #2 from teddyzeenny/multiple-resolve

Add multiple resolve test
parents 7d62cdd2 c71eca46
...@@ -90,6 +90,42 @@ describe("RSVP extensions", function() { ...@@ -90,6 +90,42 @@ describe("RSVP extensions", function() {
}); });
}); });
it('should not resolve multiple times', function(done) {
var resolver, rejector, fulfilled = 0, rejected = 0;
var thenable = {
then: function(resolve, reject) {
resolver = resolve;
rejector = reject;
}
};
var promise = RSVP.Promise(function(resolve) {
resolve(1);
});
promise.then(function(value){
return thenable;
}).then(function(value){
fulfilled++;
}, function(reason) {
rejected++;
});
setTimeout(function() {
resolver(1);
resolver(1);
rejector(1);
rejector(1);
setTimeout(function() {
assert.equal(fulfilled, 1);
assert.equal(rejected, 0);
done();
}, 20);
}, 20);
});
describe('assimilation', function() { describe('assimilation', function() {
it('should assimilate if `resolve` is called with a fulfilled promise', function(done) { it('should assimilate if `resolve` is called with a fulfilled promise', function(done) {
var originalPromise = new RSVP.Promise(function(resolve) { resolve('original value'); }); 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