chai-changes
Advanced tools
Comparing version 0.8.1 to 0.8.2
@@ -25,3 +25,3 @@ // Generated by CoffeeScript 1.3.3 | ||
chai.Assertion.addMethod('when', function(val, options) { | ||
var action, definedActions, done, _i, _j, _len, _len1, _results, | ||
var action, definedActions, done, result, _i, _j, _len, _len1, _results, | ||
_this = this; | ||
@@ -38,3 +38,4 @@ if (options == null) { | ||
} | ||
if (val.then != null) { | ||
result = val(); | ||
if (result.then != null) { | ||
done = options != null ? options.notify : void 0; | ||
@@ -44,3 +45,3 @@ if (done == null) { | ||
} | ||
return val.then(function() { | ||
return result.then(function() { | ||
var _j, _len1; | ||
@@ -56,9 +57,6 @@ try { | ||
} catch (error) { | ||
return done(error); | ||
return done(new Error(error)); | ||
} | ||
}); | ||
} else { | ||
if (typeof val === "function") { | ||
val(); | ||
} | ||
_results = []; | ||
@@ -65,0 +63,0 @@ for (_j = 0, _len1 = definedActions.length; _j < _len1; _j++) { |
@@ -6,3 +6,3 @@ { | ||
"keywords": [ "test", "assertion", "assert", "testing", "changes", "promises" ], | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
@@ -20,3 +20,3 @@ // Generated by CoffeeScript 1.3.3 | ||
}); | ||
return it('checks conditions after promise fulfilled', function(done) { | ||
it('checks conditions after promise fulfilled', function(done) { | ||
var def, result; | ||
@@ -27,3 +27,5 @@ result = 1; | ||
return result; | ||
}).to.change.when(def.promise, { | ||
}).to.change.when((function() { | ||
return def.promise; | ||
}), { | ||
notify: done | ||
@@ -34,2 +36,23 @@ }); | ||
}); | ||
return it('returns error to notify when conditions after promise fail', function(done) { | ||
var callCheck, def, result; | ||
callCheck = function(arg) { | ||
try { | ||
arg.should.eql(new Error('expected `result;` to change, but it stayed 1')); | ||
return done(); | ||
} catch (error) { | ||
return done(new Error(error)); | ||
} | ||
}; | ||
result = 1; | ||
def = window.when.defer(); | ||
expect(function() { | ||
return result; | ||
}).to.change.when((function() { | ||
return def.promise; | ||
}), { | ||
notify: callCheck | ||
}); | ||
return def.resolve(); | ||
}); | ||
}); | ||
@@ -36,0 +59,0 @@ return describe('change', function() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29882
407