-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
module.exports = { | ||
'onFinalized callback should be called without arguments on fulfill' : function(test) { | ||
var defer = Vow.defer(); | ||
defer.resolve('ok'); | ||
defer.promise().finally(function() { | ||
test.strictEqual(arguments.length, 0); | ||
test.done(); | ||
}); | ||
}, | ||
|
||
'onFinalized callback should be called without arguments on reject' : function(test) { | ||
var defer = Vow.defer(); | ||
defer.reject('error'); | ||
defer.promise().finally(function() { | ||
test.strictEqual(arguments.length, 0); | ||
test.done(); | ||
}); | ||
}, | ||
|
||
'returned promise should be fulfilled with value of original promise' : function(test) { | ||
var defer = Vow.defer(); | ||
defer.resolve('ok'); | ||
defer.promise() | ||
.finally(function() { | ||
return 'finally'; | ||
}) | ||
.then(function(val) { | ||
test.strictEqual(val, 'ok'); | ||
test.done(); | ||
}); | ||
}, | ||
|
||
'returned promise should be rejected with value of original promise' : function(test) { | ||
var defer = Vow.defer(), | ||
error = new Error('error'); | ||
defer.reject(error); | ||
defer.promise() | ||
.finally(function() { | ||
return new Error('finally'); | ||
}) | ||
.fail(function(_error) { | ||
test.strictEqual(_error, error); | ||
test.done(); | ||
}); | ||
}, | ||
|
||
'returned promise should be rejected with value of returned promise' : function(test) { | ||
var defer = Vow.defer(), | ||
error = new Error('error'), | ||
finallyError = new Error('finally'); | ||
defer.reject(error); | ||
defer.promise() | ||
.finally(function() { | ||
return Vow.reject(finallyError); | ||
}) | ||
.fail(function(_error) { | ||
test.strictEqual(_error, finallyError); | ||
test.done(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters