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

Commit 112d5d0b by Mick Hansen

refactor(belongsToMany): change tests to only look at number of sql statements a…

…nd not sql statement content
1 parent bd853b06
Showing with 2 additions and 8 deletions
...@@ -682,10 +682,7 @@ describe(Support.getTestDialectTeaser("BelongsToMany"), function() { ...@@ -682,10 +682,7 @@ describe(Support.getTestDialectTeaser("BelongsToMany"), function() {
this.Task.create({ id: 12, title: 'task1' }), this.Task.create({ id: 12, title: 'task1' }),
this.Task.create({ id: 15, title: 'task2' }), this.Task.create({ id: 15, title: 'task2' }),
]).spread(function(user, task1, task2) { ]).spread(function(user, task1, task2) {
return user.setTasks([task1, task2]).on('sql', spy).on('sql', _.after(2, function (sql) { return user.setTasks([task1, task2]).on('sql', spy);
var tickChar = (Support.getTestDialect() === 'postgres') ? '"' : '`';
expect(sql).to.have.string("INSERT INTO %TasksUsers% (%UserId%,%TaskId%) VALUES (1,12),(1,15)".replace(/%/g, tickChar));
}));
}).then(function () { }).then(function () {
expect(spy.calledTwice).to.be.ok; // Once for SELECT, once for INSERT expect(spy.calledTwice).to.be.ok; // Once for SELECT, once for INSERT
}); });
...@@ -702,10 +699,7 @@ describe(Support.getTestDialectTeaser("BelongsToMany"), function() { ...@@ -702,10 +699,7 @@ describe(Support.getTestDialectTeaser("BelongsToMany"), function() {
]).spread(function (user, task1, task2) { ]).spread(function (user, task1, task2) {
return user.setTasks([task1, task2]).return(user); return user.setTasks([task1, task2]).return(user);
}).then(function (user) { }).then(function (user) {
return user.setTasks(null).on('sql', spy).on('sql', _.after(2, function (sql) { return user.setTasks(null).on('sql', spy);
expect(sql).to.have.string("DELETE FROM");
expect(sql).to.match(/IN \(1,2\)|IN \(2,1\)/);
}));
}).then(function () { }).then(function () {
expect(spy.calledTwice).to.be.ok; // Once for SELECT, once for DELETE expect(spy.calledTwice).to.be.ok; // Once for SELECT, once for DELETE
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!