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

Commit 3aef3958 by Mick Hansen

tests for N:M and notIn

1 parent e86089e1
Showing with 41 additions and 0 deletions
...@@ -549,6 +549,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -549,6 +549,7 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
]) ])
chainer.run().success(function (results, john, task1, task2) { chainer.run().success(function (results, john, task1, task2) {
self.tasks = [task1, task2];
john.setTasks([task1, task2]).done(function(err) { john.setTasks([task1, task2]).done(function(err) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
done() done()
...@@ -607,6 +608,46 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -607,6 +608,46 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
}) })
}) })
it('supports a where not in', function (done) {
this.User.find({
where: {
username: 'John'
}
}).success(function (john) {
john.getTasks({
where: {
title: {
not: ['Get rich']
}
}
}).success(function (tasks) {
expect(tasks).to.have.length(1)
done()
})
})
});
it('supports a where not in on the primary key', function (done) {
var self = this;
this.User.find({
where: {
username: 'John'
}
}).success(function (john) {
john.getTasks({
where: {
id: {
not: [self.tasks[0].get('id')]
}
}
}).success(function (tasks) {
expect(tasks).to.have.length(1)
done()
})
})
});
it("only gets objects that fulfill options with a formatted value", function(done) { it("only gets objects that fulfill options with a formatted value", function(done) {
this.User.find({where: {username: 'John'}}).success(function (john) { this.User.find({where: {username: 'John'}}).success(function (john) {
john.getTasks({where: ['active = ?', true]}).success(function (tasks) { john.getTasks({where: ['active = ?', true]}).success(function (tasks) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!