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

Commit 07510193 by overlookmotel

Amended tests for changed findAll error handling

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