-
Notifications
You must be signed in to change notification settings - Fork 723
Allow generation of Identifier field in Playground if no validation needed #2521
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only "showstopper" is an unused variable. Your call on whether other changes are the right thing to do.
@@ -174,6 +175,7 @@ describe('ResourceComponent', () => { | |||
describe('#generateResource', () => { | |||
let mockClassDeclaration; | |||
let mockModelFile; | |||
let mockValidator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
it('should generate a valid resource with an empty ID', () => { | ||
let mockField = { | ||
getValidator: () => { | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return a String?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
return true; | ||
} | ||
}; | ||
mockClassDeclaration.getOwnProperty.returns(mockField); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know the identifier field name (in the beforeEach
) so might be worth pulling that out to a variable and using mockClassDeclaration.getOwnProperty.calledWith(idFieldName).returns(mockField);
. This is saying that all field names exist and return the same mock, but maybe that's OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
return false; | ||
} | ||
}; | ||
mockClassDeclaration.getOwnProperty.returns(mockField); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
return false; | ||
} | ||
}; | ||
mockClassDeclaration.getOwnProperty.returns(mockField); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
return false; | ||
} | ||
}; | ||
mockClassDeclaration.getOwnProperty.returns(mockField); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz re-review
@@ -289,7 +295,51 @@ describe('ResourceComponent', () => { | |||
|
|||
}); | |||
|
|||
it('should generate a valid resource with a random 4-digit ID', () => { | |||
let mockField = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth creating a Sinon stub instance of Field
just as a safety net to make sure the function you're stubbing exists -- I think Sinon will complain if you add a returns()
to a function it hasn't stubbed through introspection. Maybe that's overkill though. Your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
…uired As discussed with Simon, removing the code that adds the identifier field name to the auto generated data for relationships in Asset Signed-off-by: Sam Smith <smithsj@uk.ibm.com>
🐼 no issue? 🐼 |
No description provided.