Skip to content

Conversation

@samoshkin
Copy link

Consider following code snippet.

iit('should make related departments available, but not selected', function(){
    expect({ isAvailable: false, isSelected: false }).toHavePropertiesWithValues({ isAvailable: true, isSelected: false });
}

Above I intentionally show erroneous scenario, and got this message, which makes me think that expected object is empty or not present at all.

Expected properties with values {} to be {"isAvailable":true,"isSelected":false}.

What I expect to see is:

Expected properties with values {"isAvailable":false,"isSelected":false} to be {"isAvailable":true,"isSelected":false}.

Looking inside toHavePropertiesWithValues function at https://github.com/uxebu/jasmine-matchers/blob/master/src/toHave.js#L114, I found, that when building message, you remove all falsy properties from the object. Instead, on actual object you should remove only those properties, which are not present on expected one.

Fixed the issue.

@wolframkriesing
Copy link
Member

good find, yeah the shown data doesnt look too informative
additionally in your example i would even only show the difference in this way

Expected properties with values {"isAvailable":false} to be {"isAvailable":true}.

so you don't have to diff it in your head, but see only the things that matter

@wolframkriesing
Copy link
Member

I just tried your example with the current master, and I get

Expected properties with values {"isAvailable":false,"isSelected":false} to be {"isAvailable":true,"isSelected":false}.

did you use the latest that is in master?

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