Mongodb tolerance

This commit is contained in:
Anatoliy Chakkaev 2013-03-27 21:53:07 +04:00
parent 928a366860
commit 2d6cc9aaee
4 changed files with 28 additions and 4 deletions

View File

@ -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() {

View File

@ -1,2 +1,3 @@
require('./basic-querying.test.js');
require('./hooks.test.js');
require('./relations.test.js');

View File

@ -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();
});

View File

@ -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() {