Permalink
Browse files

resolve with falsy values

  • Loading branch information...
artjock committed Jan 24, 2013
1 parent 5dfece9 commit 7b2c406602ea32f716e8d5cbe75db21bc523527e
Showing with 14 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 lib/p.js
  3. +2 −1 package.json
  4. +10 −0 test/spec/promise.js
View
@@ -0,0 +1 @@
+node_modules
View
@@ -15,7 +15,7 @@ p.prototype = {
}
},
then: function(callback) {
- if (this.data) {
+ if ('data' in this) {
callback(this.data);
} else {
this._callbacks.push(callback);
View
@@ -16,7 +16,8 @@
},
"devDependencies": {
"mocha": "*",
- "expect.js": "*"
+ "expect.js": "*",
+ "sinon": "*"
},
"main": "lib/p",
"scripts": {
View
@@ -1,3 +1,4 @@
+var sinon = require('sinon');
var expect = require('expect.js');
var p = require('../../lib/p.js');
@@ -91,4 +92,13 @@ describe('promise', function() {
expect(res).to.eql(1);
});
+ it('should be resolved with falsy value', function() {
+ var p1 = p();
+ var callback = sinon.spy();
+
+ p1.resolve(false);
+ p1.then(callback);
+
+ expect(callback.called).to.be.ok();
+ });
});

0 comments on commit 7b2c406

Please sign in to comment.