Skip to content
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

Diff for hasProperties #8

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

Conversation

alexbepple
Copy link
Contributor

When using hasProperties we are more interested in the given properties than in anything else. So the diff becomes more useful if only the differing aspects are shown. describeMismatch uses a similar reasoning.

In order to do this, I had to change the diff API. Cp. #7 (comment)
I refactored the early beginnings that we had so far.

When creating the diff objects in hasProperties, I considered the following situations:

  • direct properties (implicit equalTo)
  • diff-capable matcher
  • non-diff-capable matcher
  • multiple nesting, e.g. __.hasProperties({a: __.hasProperties({b: __.greaterThan(2)})})

Real-life example

Before

screen shot 2014-12-11 at 13 52 42

After

(with a custom property matcher for nicer formatting)

screen shot 2014-12-11 at 20 12 28

@rluba
Copy link
Owner

rluba commented Jan 7, 2015

Hi Alex,

thank you for the pull request and sorry for the delay.

Looks great, but I think your hasProperties.getDiffItems breaks if hasProperties is a promising matcher due to promising sub-matchers. Retaining promise-awareness can be quite tricky, event when using promiseAgnostic.

Do you think you can update the PR accordingly?

Although I doubt that anyone already uses the diff API for custom matchers, I will nonetheless increase the major version when merging due to the breaking API changes.

@rluba rluba self-assigned this Jan 7, 2015
@rluba rluba added this to the 3.x milestone Jan 7, 2015
@rluba rluba mentioned this pull request Jan 7, 2015
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