Add test case using updateAttributes

This commit is contained in:
Loay 2017-04-17 18:18:20 -04:00
parent f1d10b47ce
commit 3c19beacbb
1 changed files with 59 additions and 48 deletions

View File

@ -913,7 +913,8 @@ describe('manipulation', function() {
});
});
describe('updateOrCreate when forceId is true', function() {
bdd.describeIf(connectorCapabilities.supportForceId !== false,
'updateOrCreate when forceId is true', function() {
var Post;
before(function definePostModel(done) {
var ds = getSchema();
@ -942,6 +943,16 @@ describe('manipulation', function() {
});
});
it('fails when id does not exist in db & validate is false when using updateAttributes',
function(done) {
var unknownId = uid.fromConnector(db) || 123;
var post = new Post({id: unknownId});
post.updateAttributes({title: 'updated title', content: 'AAA'}, {validate: false}, (err) => {
err.statusCode.should.equal(404);
done();
});
});
it('works on create if the request does not include an id', function(done) {
var post = {title: 'a', content: 'AAA'};
Post.updateOrCreate(post, (err, p) => {