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

Commit 72392dcd by Sascha Depold

added basic test for fetching associations

1 parent 720e40fb
Showing with 15 additions and 3 deletions
...@@ -5,14 +5,26 @@ var Sequelize = require(__dirname + "/../../lib/sequelize/Sequelize").Sequelize, ...@@ -5,14 +5,26 @@ var Sequelize = require(__dirname + "/../../lib/sequelize/Sequelize").Sequelize,
module.exports = { module.exports = {
'should store data inside the fetchedAssociations hash': function(assert, beforeExit) { 'should have no fetchedAssociations first': function(assert, beforeExit) {
var allowExit = false var allowExit = false
Foo.hasMany('bars', Bar, 'foos') Foo.hasMany('bars', Bar, 'foos')
Sequelize.chainQueries([{drop: s}, {sync: s}], function() { Sequelize.chainQueries([{drop: s}, {sync: s}], function() {
var foo = new Foo({name:'asd'}) new Foo({name:'asd'}).save(function() {
foo.save(function() {
assert.eql(foo.fetchedAssociations, {}) assert.eql(foo.fetchedAssociations, {})
allowExit = true
})
})
beforeExit(function() { assert.eql(allowExit, true) })
},
'should have an empty array for each table association': function(assert, beforeExit) {
var allowExit = false
Foo.hasMany('bars', Bar, 'foos')
Sequelize.chainQueries([{drop: s}, {sync: s}], function() {
new Foo({name:'asd'}).save(function() {
foo.fetchAssociations(function() { foo.fetchAssociations(function() {
assert.eql(foo.fetchedAssociations, {bars: []}) assert.eql(foo.fetchedAssociations, {bars: []})
allowExit = true allowExit = true
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!