Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Fix deep object acess #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Thomas-P
Copy link

@Thomas-P Thomas-P commented Feb 4, 2018

Hi,

I fixed a possible deep object acess problem, where we could not predict if the first object has a value on the property. That could cause in an error thrown by the engine.

The second fix is in the test definition, where the test against undefined object did not call the awaited function. Thats why nothing is tested in these test cases.

I added .idea for the Intelij IDE to .gitignore. Hope this is ok.

Have a nice Weekend,

Thomas

@Thomas-P
Copy link
Author

Thomas-P commented Feb 4, 2018

Ah,

I forgot to mention, that I also removed some try to hack typescript, because they aren't needed. Wish that you use semicolons, but that is another story. ;)

@@ -97,7 +97,7 @@ export interface RecordAckMessage extends RecordMessage {
}

export interface ParseError {
parseError: boolean
parseError: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks in node 6 sadly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will review this on the next weekend.

@@ -17,7 +17,7 @@ describe('message parser', () => {
}
it (`parses ${TOPIC[topic]} messages ${authAction} correctly`, () => {
const result = parse(spec.urp.value)[0]
expect(result.parseError).to.be.undefined
expect(result.parseError).to.be.an('undefined')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the difference with these out of curiosity?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one

expect(result.parseError).to.be.undefined

hides information of an method call in an getter method called when you call an attribute. This might be fine, but on a reviewer perspective I'm not able to predict side effects or able to jump in the method, which is called by accessing the attribute. I'm also not so happy with my one, because it mixes types, which is also a problem. This one was provided as a solution on the documentation of chai in bdd style.

On my opinion the best is to switch to the assert methods which are also provided by chai. The isUndefined-method should do what expected.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants