'test errback+callback from constructor': function (beforeExit) { var promise = new Promise(function (err) { err.should.be.an.instanceof(Error); called++; }) , called = 0; promise.error(new Error('dawg')); beforeExit(function () { called.should.eql(1); }); },
'test addErrback shortcut': function (beforeExit) { var promise = new Promise() , called = 0; promise.addErrback(function (err) { err.should.be.an.instanceof(Error); called++; }); promise.error(new Error); beforeExit(function () { called.should.eql(1); }); }
'test errback+callback after error()ing': function (beforeExit) { var promise = new Promise() , called = 0; promise.error(new Error('woot')); promise.addBack(function (err){ err.should.be.an.instanceof(Error); called++; }); promise.addBack(function (err){ err.should.be.an.instanceof(Error); called++; }); beforeExit(function () { called.should.eql(2); }); },
'test that events fire right away after error()ing': function (beforeExit) { var promise = new Promise() , called = 0; promise.on('err', function (err) { err.should.be.an.instanceof(Error); called++; }); promise.error(new Error('booyah')); promise.on('err', function (err) { err.should.be.an.instanceof(Error); called++; }); beforeExit(function () { called.should.eql(2); }); },