Additonal test case

This commit is contained in:
Anatoliy Chakkaev 2012-12-15 00:09:42 +04:00
parent 396393ce62
commit e78fab6f5b
2 changed files with 22 additions and 4 deletions

View File

@ -2,12 +2,12 @@ juggling = require('jugglingdb')
Schema = juggling.Schema
Text = Schema.Text
DBNAME = process.env.DBNAME || 'myapp_test'
DBUSER = process.env.DBUSER || 'root'
DBNAME = 'myapp_test'
DBUSER = 'root'
DBPASS = ''
DBENGINE = process.env.DBENGINE || 'mysql'
DBENGINE = 'mysql'
schema = new Schema DBENGINE, database: '', username: DBUSER, password: DBPASS
schema = new Schema __dirname + '/..', database: '', username: DBUSER, password: DBPASS
schema.log = (q) -> console.log q
query = (sql, cb) ->

View File

@ -8,3 +8,21 @@ var jdb = require('jugglingdb'),
test(module.exports, schema);
var Post, User;
test.it('hasMany should support additional conditions', function (test) {
Post = schema.models.Post;
User = schema.models.User;
User.create(function (e, u) {
u.posts.create({}, function (e, p) {
u.posts({where: {id: p.id}}, function (e, posts) {
test.equal(posts.length, 1, 'There should be only 1 post.');
test.done();
});
});
});
});