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

Commit 07510193 by overlookmotel

Amended tests for changed findAll error handling

1 parent 5fccccb4
......@@ -332,19 +332,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
describe('generic', function() {
it('throws an error about unexpected input if include contains a non-object', function(done) {
var self = this
expect(function() {
self.Worker.find({ include: [ 1 ] })
}).to.throw(Error)
self.Worker.find({ include: [ 1 ] }).catch(function(err) {
expect(err.message).to.equal('Include unexpected. Element has to be either a Model, an Association or an object.');
done()
})
})
it('throws an error if included DaoFactory is not associated', function(done) {
var self = this
expect(function() {
self.Worker.find({ include: [ self.Task ] })
}).to.throw(Error, 'Task is not associated to Worker!')
self.Worker.find({ include: [ self.Task ] }).catch(function(err) {
expect(err.message).to.equal('Task is not associated to Worker!');
done()
})
})
it('returns the associated worker via task.worker', function(done) {
var self = this
......@@ -518,11 +518,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error if included DaoFactory is not associated', function(done) {
var self = this
expect(function() {
self.Task.find({ include: [ self.Worker ] })
}).to.throw(Error, 'Worker is not associated to Task!')
self.Task.find({ include: [ self.Worker ] }).catch(function(err) {
expect(err.message).to.equal('Worker is not associated to Task!');
done()
})
})
it('returns the associated task via worker.task', function(done) {
this.Worker.find({
......@@ -577,11 +577,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
describe('hasOne with alias', function() {
it('throws an error if included DaoFactory is not referenced by alias', function(done) {
var self = this
expect(function() {
self.Worker.find({ include: [ self.Task ] })
}).to.throw(Error, 'Task is not associated to Worker!')
self.Worker.find({ include: [ self.Task ] }).catch(function(err) {
expect(err.message).to.equal('Task is not associated to Worker!');
done()
})
})
describe('alias', function() {
beforeEach(function(done) {
......@@ -596,11 +596,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error if alias is not associated', function(done) {
var self = this
expect(function() {
self.Worker.find({ include: [ { daoFactory: self.Task, as: 'Work' } ] })
}).to.throw(Error, 'Task (Work) is not associated to Worker!')
self.Worker.find({ include: [ { daoFactory: self.Task, as: 'Work' } ] }).catch(function(err) {
expect(err.message).to.equal('Task (Work) is not associated to Worker!');
done()
})
})
it('returns the associated task via worker.task', function(done) {
this.Worker.find({
......@@ -657,11 +657,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error if included DaoFactory is not associated', function(done) {
var self = this
expect(function() {
self.Task.find({ include: [ self.Worker ] })
}).to.throw(Error, 'Worker is not associated to Task!')
self.Task.find({ include: [ self.Worker ] }).catch(function(err) {
expect(err.message).to.equal('Worker is not associated to Task!');
done()
})
})
it('returns the associated tasks via worker.tasks', function(done) {
this.Worker.find({
......@@ -759,11 +759,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
describe('hasMany with alias', function() {
it('throws an error if included DaoFactory is not referenced by alias', function(done) {
var self = this
expect(function() {
self.Worker.find({ include: [ self.Task ] })
}).to.throw(Error, 'Task is not associated to Worker!')
self.Worker.find({ include: [ self.Task ] }).catch(function(err) {
expect(err.message).to.equal('Task is not associated to Worker!');
done()
})
})
describe('alias', function() {
beforeEach(function(done) {
......@@ -778,11 +778,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error if alias is not associated', function(done) {
var self = this
expect(function() {
self.Worker.find({ include: [ { daoFactory: self.Task, as: 'Work' } ] })
}).to.throw(Error, 'Task (Work) is not associated to Worker!')
self.Worker.find({ include: [ { daoFactory: self.Task, as: 'Work' } ] }).catch(function(err) {
expect(err.message).to.equal('Task (Work) is not associated to Worker!');
done()
})
})
it('returns the associated task via worker.task', function(done) {
this.Worker.find({
......
......@@ -575,19 +575,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error about unexpected input if include contains a non-object', function(done) {
var self = this
expect(function() {
self.Worker.all({ include: [ 1 ] })
}).to.throw(Error)
self.Worker.all({ include: [ 1 ] }).catch(function(err) {
expect(err.message).to.equal('Include unexpected. Element has to be either a Model, an Association or an object.');
done()
})
})
it('throws an error if included DaoFactory is not associated', function(done) {
var self = this
expect(function() {
self.Worker.all({ include: [ self.Task ] })
}).to.throw(Error, 'TaskBelongsTo is not associated to Worker!')
self.Worker.all({ include: [ self.Task ] }).catch(function(err) {
expect(err.message).to.equal('TaskBelongsTo is not associated to Worker!');
done()
})
})
it('returns the associated worker via task.worker', function(done) {
this.Task.all({
......@@ -627,11 +627,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error if included DaoFactory is not associated', function(done) {
var self = this
expect(function() {
self.Task.all({ include: [ self.Worker ] })
}).to.throw(Error, 'Worker is not associated to TaskHasOne!')
self.Task.all({ include: [ self.Worker ] }).catch(function(err) {
expect(err.message).to.equal('Worker is not associated to TaskHasOne!');
done()
})
})
it('returns the associated task via worker.task', function(done) {
this.Worker.all({
......@@ -672,19 +672,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error if included DaoFactory is not referenced by alias', function(done) {
var self = this
expect(function() {
self.Worker.all({ include: [ self.Task ] })
}).to.throw(Error, 'Task is not associated to Worker!')
self.Worker.all({ include: [ self.Task ] }).catch(function(err) {
expect(err.message).to.equal('Task is not associated to Worker!');
done()
})
})
it('throws an error if alias is not associated', function(done) {
var self = this
expect(function() {
self.Worker.all({ include: [ { daoFactory: self.Task, as: 'Work' } ] })
}).to.throw(Error, 'Task (Work) is not associated to Worker!')
self.Worker.all({ include: [ { daoFactory: self.Task, as: 'Work' } ] }).catch(function(err) {
expect(err.message).to.equal('Task (Work) is not associated to Worker!');
done()
})
})
it('returns the associated task via worker.task', function(done) {
this.Worker.all({
......@@ -735,11 +735,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error if included DaoFactory is not associated', function(done) {
var self = this
expect(function() {
self.Task.findAll({ include: [ self.Worker ] })
}).to.throw(Error, 'worker is not associated to task!')
self.Task.findAll({ include: [ self.Worker ] }).catch(function(err) {
expect(err.message).to.equal('worker is not associated to task!');
done()
})
})
it('returns the associated tasks via worker.tasks', function(done) {
this.Worker.findAll({
......@@ -780,19 +780,19 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
it('throws an error if included DaoFactory is not referenced by alias', function(done) {
var self = this
expect(function() {
self.Worker.findAll({ include: [ self.Task ] })
}).to.throw(Error, 'Task is not associated to Worker!')
self.Worker.findAll({ include: [ self.Task ] }).catch(function(err) {
expect(err.message).to.equal('Task is not associated to Worker!');
done()
})
})
it('throws an error if alias is not associated', function(done) {
var self = this
expect(function() {
self.Worker.findAll({ include: [ { daoFactory: self.Task, as: 'Work' } ] })
}).to.throw(Error, 'Task (Work) is not associated to Worker!')
self.Worker.findAll({ include: [ { daoFactory: self.Task, as: 'Work' } ] }).catch(function(err) {
expect(err.message).to.equal('Task (Work) is not associated to Worker!');
done()
})
})
it('returns the associated task via worker.task', function(done) {
this.Worker.findAll({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!