diff --git a/test/basic-querying.test.js b/test/basic-querying.test.js index 5129c5af..4e5fb736 100644 --- a/test/basic-querying.test.js +++ b/test/basic-querying.test.js @@ -146,7 +146,7 @@ describe('basic-querying', function() { User.findOne(function(e, u) { should.not.exist(e); should.exist(u); - u.id.should.equal(users[0].id); + u.id.toString().should.equal(users[0].id.toString()); done(); }); }); @@ -185,6 +185,16 @@ describe('basic-querying', function() { }); }); + it.only('should work even when find by id', function(done) { + User.findOne(function(e, u) { + User.findOne({where: {id: u.id}}, function(err, user) { + should.not.exist(err); + should.exist(user); + done(); + }); + }); + }); + }); describe('exists', function() { diff --git a/test/common.batch.js b/test/common.batch.js index 9f0b4e40..f93f4535 100644 --- a/test/common.batch.js +++ b/test/common.batch.js @@ -1,2 +1,3 @@ require('./basic-querying.test.js'); require('./hooks.test.js'); +require('./relations.test.js'); diff --git a/test/hooks.test.js b/test/hooks.test.js index 47031856..462f51dd 100644 --- a/test/hooks.test.js +++ b/test/hooks.test.js @@ -42,7 +42,7 @@ describe('hooks', function() { } }; User.create({name: 'Nickolay'}, function(err, u) { - u.id.should.be.a('number'); + u.id.should.be.ok; u.name.should.equal('Nickolay Rozental'); done(); }); diff --git a/test/relations.test.js b/test/relations.test.js index b41a606e..44eb8a52 100644 --- a/test/relations.test.js +++ b/test/relations.test.js @@ -43,7 +43,7 @@ describe('relations', function() { (new Author).readers.should.be.an.instanceOf(Function); Object.keys((new Reader).toObject()).should.include('authorId'); - db.automigrate(done); + db.autoupdate(done); }); it('should build record on scope', function(done) { @@ -115,7 +115,20 @@ describe('relations', function() { // (new Fear).mind.build().should.be.an.instanceOf(Mind); }); - it('can be declared in short form'); + it('can be used to query data', function(done) { + List.hasMany('todos', {model: Item}); + List.create(function(e, list) { + should.not.exist(e); + should.exist(list); + list.todos.create(function(err, todo) { + todo.list(function(e, l) { + should.not.exist(e); + should.exist(l); + done(); + }); + }); + }); + }); }); describe('hasAndBelongsToMany', function() {