Skip to content

Commit

Permalink
fixup! apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
biniam committed Feb 20, 2019
1 parent db39d78 commit a9d4a3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Connector.getNestedPropertyDefinition = function(definition, propPath) {
if (propPath.length === 1) return prop;

if (isPropUndefined || (propPath.length > 1 && (isArray && prop.type.length === 0))) {
throw new Error(g.f('Invalid property path'));
return undefined;
}

const nextDefinition =
Expand Down
11 changes: 5 additions & 6 deletions test/connector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ describe('Connector', () => {
expect(propDefinition.type).to.equal(Date);
});

it('should fail for non-existing properties', () => {
expect(() =>
connector.getPropertyDefinition(
'MyModel',
'non.existing.property'
)).to.throw(/Invalid property path/);
it('should return undefined for non-existing properties', () => {
const definition = connector.getPropertyDefinition('MyModel',
'non.existing.property');
// eslint-disable-next-line no-unused-expressions
expect(definition).to.be.undefined;
});

it('should preserve backward-compatibility for non-existing property', () => {
Expand Down

0 comments on commit a9d4a3f

Please sign in to comment.