add test suit for scope - dynamic function
This commit is contained in:
parent
d8ecea6111
commit
61dc239bd8
|
@ -387,3 +387,35 @@ describe('scope - dynamic target class', function () {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
describe('scope - dynamic function', function () {
|
||||
|
||||
var Item,seed=0;
|
||||
|
||||
before(function () {
|
||||
db = getSchema();
|
||||
Item = db.define('Item', {title: Number,creator:Number});
|
||||
Item.scope('dynamicQuery', function () {
|
||||
seed++;
|
||||
return {where:{creator:seed}};
|
||||
})
|
||||
});
|
||||
|
||||
beforeEach(function (done) {
|
||||
Item.create({ title:1,creator:1 }, function () {
|
||||
Item.create({ title:2,creator:2 },done)
|
||||
})
|
||||
});
|
||||
|
||||
it('should deduce item by runtime creator', function (done) {
|
||||
Item.dynamicQuery.findOne(function (err,firstQuery) {
|
||||
should.not.exist(err);
|
||||
firstQuery.title.should.equal(1);
|
||||
Item.dynamicQuery.findOne(function (err,secondQuery) {
|
||||
should.not.exist(err);
|
||||
secondQuery.title.should.equal(2);
|
||||
done();
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue