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

Commit 21074872 by Mick Hansen

feat(promises): example of better(?) test

1 parent c9368843
Showing with 18 additions and 22 deletions
...@@ -1331,28 +1331,24 @@ describe(Support.getTestDialectTeaser("HasMany"), function() { ...@@ -1331,28 +1331,24 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
Worker.hasMany(Task, { through: WorkerTasks }) Worker.hasMany(Task, { through: WorkerTasks })
Task.hasMany(Worker, { through: WorkerTasks }) Task.hasMany(Worker, { through: WorkerTasks })
this.sequelize.sync().done(function(err) { // Test setup
expect(err).not.to.be.ok this.sequelize.sync().then(function() {
Worker.create({}).done(function (err, worker) { return Sequelize.Promise.all([
expect(err).not.to.be.ok Worker.create({}),
Task.bulkCreate([{}, {}]).done(function (err) { Task.bulkCreate([{}, {}]).then(function () {
expect(err).not.to.be.ok return Task.findAll()
Task.findAll().done(function (err, tasks) { })
expect(err).not.to.be.ok ]);
worker.setTasks(tasks).done(function () { }).spread(function (worker, tasks) {
worker.removeTask(tasks[0]).done(function (err) { // Set all tasks, then remove one tasks, then return all tasks
expect(err).not.to.be.ok return worker.setTasks(tasks).then(function () {
return worker.removeTask(tasks[0]);
worker.getTasks().done(function (err, tasks) { }).then(function () {
expect(tasks.length).to.equal(1) return worker.getTasks();
done() });
}) }).then(function (tasks) {
}) expect(tasks.length).to.equal(1);
}) }).then(done.bind(null, null), done);
})
})
})
})
}) })
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!