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

Commit 07510193 by overlookmotel

Amended tests for changed findAll error handling

1 parent 5fccccb4
......@@ -332,18 +332,18 @@ 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)
done()
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!')
done()
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) {
......@@ -518,10 +518,10 @@ 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!')
done()
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) {
......@@ -577,10 +577,10 @@ 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!')
done()
self.Worker.find({ include: [ self.Task ] }).catch(function(err) {
expect(err.message).to.equal('Task is not associated to Worker!');
done()
})
})
describe('alias', function() {
......@@ -596,10 +596,10 @@ 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!')
done()
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) {
......@@ -657,10 +657,10 @@ 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!')
done()
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) {
......@@ -759,10 +759,10 @@ 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!')
done()
self.Worker.find({ include: [ self.Task ] }).catch(function(err) {
expect(err.message).to.equal('Task is not associated to Worker!');
done()
})
})
describe('alias', function() {
......@@ -778,10 +778,10 @@ 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!')
done()
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) {
......
......@@ -575,18 +575,18 @@ 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)
done()
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!')
done()
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) {
......@@ -627,10 +627,10 @@ 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!')
done()
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) {
......@@ -672,18 +672,18 @@ 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!')
done()
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!')
done()
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) {
......@@ -735,10 +735,10 @@ 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!')
done()
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) {
......@@ -780,18 +780,18 @@ 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!')
done()
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!')
done()
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) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!