Skip to content

Fix unit tests #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2019
Merged

Fix unit tests #1

merged 3 commits into from
Oct 31, 2019

Conversation

maxceem
Copy link
Contributor

@maxceem maxceem commented Oct 31, 2019

There was an issue so all the unit tests always passed.

This issue was fixed. After that, some issues become visible in existent unit tests, so they were fixed.

Fixed method expectObj() which is used to assert objects. Before it always return true for any passed values.
The reason for that was that "_.pick(obj1, _.identity)" returns an empty object {} for any obj1.
This test failed after the fixing of expectObj() method.
This issue become visible after fixing the expectObj() method.
The thing here is that when we use .empty(null) in Joi then if property is passed as "null" it's stripped from the object.
As a result, we pass an object with "null" value, but we are trying to save in ES the object without value.
This leads to the unit test fails, as saved value doesn't match the object which has been send in the message.
@vikasrohit
Copy link

Good catch @maxceem about the passing tests. If I understand correctly, the comparison helper method was failing when any of the passed arguments as undefined and causing the tests to be passed?

@vikasrohit vikasrohit merged commit af22dec into topcoder-platform:develop Oct 31, 2019
@maxceem
Copy link
Contributor Author

maxceem commented Oct 31, 2019

If I understand correctly, the comparison helper method was failing when any of the passed arguments as undefined and causing the tests to be passed?

The helper method always returned "true" i. e. test always pass no matter what data we pass to this method:

  • expectObj(undefined, {a: 1}) => true
  • expectObj({b: 2}, {a: 1}) => true

So for two different objects, it also returned true.

maxceem added a commit that referenced this pull request Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants