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

Commit 07510193 by overlookmotel

Amended tests for changed findAll error handling

1 parent 5fccccb4
...@@ -332,18 +332,18 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -332,18 +332,18 @@ 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) {
...@@ -518,10 +518,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -518,10 +518,10 @@ 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) {
...@@ -577,10 +577,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -577,10 +577,10 @@ 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() {
...@@ -596,10 +596,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -596,10 +596,10 @@ 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) {
...@@ -657,10 +657,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -657,10 +657,10 @@ 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) {
...@@ -759,10 +759,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -759,10 +759,10 @@ 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() {
...@@ -778,10 +778,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -778,10 +778,10 @@ 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) {
......
...@@ -575,18 +575,18 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -575,18 +575,18 @@ 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) {
...@@ -627,10 +627,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -627,10 +627,10 @@ 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) {
...@@ -672,18 +672,18 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -672,18 +672,18 @@ 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) {
...@@ -735,10 +735,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -735,10 +735,10 @@ 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) {
...@@ -780,18 +780,18 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -780,18 +780,18 @@ 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) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!