Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add error method

  • Loading branch information...
commit 33e55fde348ff31df89699c48355ec6d64458c03 1 parent c7aa938
@atsuya authored
Showing with 18 additions and 0 deletions.
  1. +4 −0 lib/done-criteria.js
  2. +14 −0 test/done-criteria.test.js
View
4 lib/done-criteria.js
@@ -23,4 +23,8 @@ DoneCriteria.prototype.done = function() {
}
};
+DoneCriteria.prototype.error = function(error) {
+ return this.callback(error);
+};
+
module.exports = DoneCriteria;
View
14 test/done-criteria.test.js
@@ -83,4 +83,18 @@ describe('done-criteria', function() {
setTimeout(function() { done(); }, 1500);
});
});
+
+ context('with errors', function() {
+ it('calls callback with error', function(done) {
+ var errorMessage = 'error message'
+ , doneCriteria = new DoneCriteria(['unko', 'geri'], function(error) {
+ helper.should.exist(error);
+ error.message.should.equal(errorMessage);
+ done();
+ });
+
+ doneCriteria.done('geri');
+ doneCriteria.error(new Error(errorMessage));
+ });
+ });
});
Please sign in to comment.
Something went wrong with that request. Please try again.