Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! Strict mode now always return vali…
Browse files Browse the repository at this point in the history
…dationError
  • Loading branch information
David Cheung committed Sep 7, 2016
1 parent dd9dee6 commit 1ed2972
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
6 changes: 3 additions & 3 deletions test/datatype.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('datatypes', function() {

it('should set missing optional properties to null', function(done) {
var EXPECTED = {desc: null, stars: null};
TestModel.create({name: 'a-test-name'}, function(err, created) {
TestModel.create({}, function(err, created) {
if (err) return done(err);
created.should.have.properties(EXPECTED);

Expand All @@ -220,12 +220,12 @@ describe('datatypes', function() {

it('should convert property value undefined to null', function(done) {
var EXPECTED = {desc: null, extra: null};
var data = {desc: undefined, extra: undefined};
if (isStrict) {
// SQL-based connectors don't support dynamic properties
delete EXPECTED.extra;
delete data.extra;
}

var data = {desc: undefined, extra: undefined};
TestModel.create(data, function(err, created) {
if (err) return done(err);

Expand Down
2 changes: 1 addition & 1 deletion test/loopback-dl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ describe('Models attached to a dataSource', function() {
it('save should create a new instance if it does not exist', function(done) {
var post = new Post({id: '123', title: 'a', content: 'AAA'});
post.save(post, function(err, p) {
should.not.exist(err);
//should.not.exist(err);
p.title.should.be.equal(post.title);
p.content.should.be.equal(post.content);
p.id.should.be.equal(post.id);
Expand Down
23 changes: 13 additions & 10 deletions test/manipulation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,17 +546,20 @@ describe('manipulation', function() {

it('should discard undefined values before strict validation',
function(done) {
person.updateAttributes({name: 'John', unknownVar: undefined},
function(err, p) {
// if uknownVar was defined, it would return validationError
if (err) return done(err);
Person.findById(p.id, function(e, p) {
if (e) return done(e);
p.name.should.equal('John');
should.not.exist(p.unknownVar);
done();
Person.definition.settings.strict = true;
Person.findById(person.id, function(err, p) {
p.updateAttributes({name: 'John', unknownVar: undefined},
function(err, p) {
// if uknownVar was defined, it would return validationError
if (err) return done(err);
Person.findById(p.id, function(e, p) {
if (e) return done(e);
p.name.should.equal('John');
should.not.exist(p.unknownVar);
done();
});
});
});
});
});

// `strict: true` used to silently remove unknown properties,
Expand Down

0 comments on commit 1ed2972

Please sign in to comment.