不要怂,就是干,撸起袖子干!

Commit 7c90ba6e by Jan Aagaard Meier

Added .catch to custom event emitter

1 parent 8b0b03c8
......@@ -161,5 +161,9 @@ module.exports = (function() {
}).spread(onFulfilled, onRejected)
}
CustomEventEmitter.prototype.catch = function(onRejected) {
return this.then(null, onRejected)
}
return CustomEventEmitter
})()
......@@ -272,7 +272,8 @@ describe(Support.getTestDialectTeaser("Promise"), function () {
describe('save', function () {
it('should fail a validation upon creating', function(done) {
this.User.create({aNumber: 0, validateTest: 'hello'}).then(null, function(err) {
this.User.create({aNumber: 0, validateTest: 'hello'})
.catch(function(err) {
expect(err).to.be.ok
expect(err).to.be.an("object")
expect(err.validateTest).to.be.an("array")
......@@ -284,7 +285,7 @@ describe(Support.getTestDialectTeaser("Promise"), function () {
it('should fail a validation upon building', function(done) {
this.User.build({aNumber: 0, validateCustom: 'aaaaaaaaaaaaaaaaaaaaaaaaaa'}).save()
.then(null, function(err) {
.catch(function(err) {
expect(err).to.be.ok
expect(err).to.be.an("object")
expect(err.validateCustom).to.be.ok
......@@ -298,7 +299,7 @@ describe(Support.getTestDialectTeaser("Promise"), function () {
it('should fail a validation when updating', function(done) {
this.User.create({aNumber: 0}).then(function (user) {
return user.updateAttributes({validateTest: 'hello'})
}).then(null, function(err) {
}).catch(function(err) {
expect(err).to.be.ok
expect(err).to.be.an("object")
expect(err.validateTest).to.be.ok
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!