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

Commit b1875abb by overlookmotel

Tests for universal hooks

1 parent e90e7d37
Showing with 30 additions and 0 deletions
......@@ -4322,6 +4322,36 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
});
});
describe('universal', function() {
beforeEach(function(done) {
this.sequelize.addHook('beforeFind', function(options) {
options.where.name = 'Chong';
});
this.Person = this.sequelize.define('Person', {name: DataTypes.STRING});
this.Person.sync({ force: true }).bind(this).then(function() {
return this.Person.create({name: 'Cheech'});
}).then(function() {
return this.Person.create({name: 'Chong'});
}).then(function() {
done();
});
});
it('hooks run on all models', function(done) {
this.Person.find({where: {name: 'Cheech'}}).then(function(person) {
expect(person.name).to.equal('Chong');
done();
});
});
afterEach(function(done) {
this.sequelize.options.hooks = {};
done();
});
});
describe('aliases', function() {
describe('direct method', function() {
describe('#delete', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!