Fix test for "after save" called on save/CREATE

Fix the test to correctly trigger the code path where the connector
decides whether a new record is created or an existing one is updated.
This commit is contained in:
Miroslav Bajtoš 2015-04-01 18:25:45 +02:00
parent 3a51510119
commit a00b91db79
1 changed files with 8 additions and 3 deletions

View File

@ -525,7 +525,8 @@ module.exports = function(dataSource, should) {
extra: undefined
},
isNewInstance: false,
options: { throws: false, validate: true } }));
options: { throws: false, validate: true }
}));
done();
});
});
@ -533,7 +534,10 @@ module.exports = function(dataSource, should) {
it('triggers `after save` hook on create', function(done) {
TestModel.observe('after save', pushContextAndNext());
var instance = new TestModel({ name: 'created' });
var instance = new TestModel(
{ id: 'new-id', name: 'created' },
{ persisted: true });
instance.save(function(err, instance) {
if (err) return done(err);
observedContexts.should.eql(aTestModelCtx({
@ -542,7 +546,8 @@ module.exports = function(dataSource, should) {
name: 'created',
extra: undefined
},
isNewInstance: true
isNewInstance: true,
options: { throws: false, validate: true }
}));
done();
});