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

refactor hooks tests to support new Error pattern

1 parent 59d48328
Showing with 25 additions and 13 deletions
...@@ -463,7 +463,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -463,7 +463,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
describe('#create', function() { describe('#create', function() {
it('should return an error based on user', function(done) { it('should return an error based on user', function(done) {
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal([ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ])
done() done()
}) })
}) })
...@@ -499,7 +500,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -499,7 +500,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
describe('#create', function() { describe('#create', function() {
it('should return an error based on the hook', function(done) { it('should return an error based on the hook', function(done) {
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal([ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ])
done() done()
}) })
}) })
...@@ -549,7 +551,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -549,7 +551,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
describe('#create', function() { describe('#create', function() {
it('should return an error based on user', function(done) { it('should return an error based on user', function(done) {
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal([ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ])
done() done()
}) })
}) })
...@@ -597,7 +600,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -597,7 +600,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
describe('#create', function() { describe('#create', function() {
it('should return an error based on the hook', function(done) { it('should return an error based on the hook', function(done) {
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal([ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ])
done() done()
}) })
}) })
...@@ -693,7 +697,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -693,7 +697,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
describe('#create', function() { describe('#create', function() {
it('should return the user from the callback', function(done) { it('should return the user from the callback', function(done) {
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal([ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ])
done() done()
}) })
}) })
...@@ -714,7 +719,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -714,7 +719,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
describe('#create', function() { describe('#create', function() {
it('should return the error without the user within callback', function(done) { it('should return the error without the user within callback', function(done) {
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal([ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ])
done() done()
}) })
}) })
...@@ -828,7 +834,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -828,7 +834,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
it('#create', function(done) { it('#create', function(done) {
this.User.create({mood: 'creative'}).error(function(err) { this.User.create({mood: 'creative'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal( [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] )
done() done()
}) })
}) })
...@@ -851,7 +858,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -851,7 +858,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
it('#create', function(done) { it('#create', function(done) {
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal( [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] )
done() done()
}) })
}) })
...@@ -931,7 +939,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -931,7 +939,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
}) })
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal( [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] )
done() done()
}) })
}) })
...@@ -944,7 +953,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -944,7 +953,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
}) })
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal( [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] )
done() done()
}) })
}) })
...@@ -1050,7 +1060,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -1050,7 +1060,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
it('#create', function(done) { it('#create', function(done) {
this.User.create({mood: 'creative'}).error(function(err) { this.User.create({mood: 'creative'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal( [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] )
done() done()
}) })
}) })
...@@ -1073,7 +1084,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -1073,7 +1084,8 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
it('#create', function(done) { it('#create', function(done) {
this.User.create({mood: 'happy'}).error(function(err) { this.User.create({mood: 'happy'}).error(function(err) {
expect(err).to.deep.equal({ mood: [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] }) expect(err).to.be.instanceOf(Error);
expect(err.mood).to.deep.equal( [ 'Value "ecstatic" for ENUM mood is out of allowed scope. Allowed values: happy, sad, neutral' ] )
done() done()
}) })
}) })
...@@ -1883,7 +1895,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () { ...@@ -1883,7 +1895,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
hookCalled++ hookCalled++
next() next()
}) })
B.hasMany(A) B.hasMany(A)
A.hasMany(B) A.hasMany(B)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!