Perhaps I do not understand what bind is suppose to do? I would expect both of these tests to pass.
node: 0.12.7
bluebird: 2.9.33
var expect = require('chai').expect;
var Promise = require('bluebird');
describe('Derived promises should have the bound context', function () {
it('when the context is an object', function() {
return Promise
.bind({hasContext: true})
.then(function(){
expect(this.hasContext).to.be.true()
})
.then(function(){
expect(this.hasContext).to.be.true()
})
.then(function(){
expect(this.hasContext).to.be.true()
})
.then(function(){
expect(this.hasContext).to.be.true()
})
.then(function(){
expect(this.hasContext).to.be.true()
})
})
// This fails :(
it('when the context is a Promise', function() {
return Promise
.bind(new Promise(function(resolve){
setTimeout(function(){
resolve({hasContext: true})
}, 100)
}))
.then(function(){
// this will pass
expect(this.hasContext).to.be.true()
})
.then(function(){
// these all fail
expect(this.hasContext).to.be.true()
})
.then(function(){
expect(this.hasContext).to.be.true()
})
.then(function(){
expect(this.hasContext).to.be.true()
})
.then(function(){
expect(this.hasContext).to.be.true()
})
})
})
Perhaps I do not understand what
bindis suppose to do? I would expect both of these tests to pass.node: 0.12.7
bluebird: 2.9.33