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

Add tmatch support to expect(object).toMatch #81

Closed
elado opened this issue Mar 24, 2016 · 2 comments
Closed

Add tmatch support to expect(object).toMatch #81

elado opened this issue Mar 24, 2016 · 2 comments

Comments

@elado
Copy link
Contributor

elado commented Mar 24, 2016

tmatch does a better job of deeply checking for a partial object in another.

Specifically with:

  • matching arrays and nested objects in arrays.
  • comparing dates
  • matching RegExp to a string

Should we change the code (as I PRed @ #80) to use it?

tmatch(
  {a: 1, b: 2, c: {d: 4, e: {f: 5, g: 6}, h: 7}, i: [{j: 8}, {k: 9, l: 10}], m: 'hello' },
  { b: 2, c: {d: 4, e: {g: 6}}, i:[ {j: 8}, {k: 9} ], m: /ll/ }
)
@ljharb
Copy link
Collaborator

ljharb commented Mar 25, 2016

A PR that adds test cases that pass with tmatch but fail with the current implementation would be a good start.

@mjackson
Copy link
Owner

mjackson commented Apr 4, 2016

We already have a toMatch method. Maybe we should augment that with tmatch-style support instead of further modifying toInclude? IMO "include" methods should check the expected value is a subset of the actual value, respecting types. "match" methods make it more obvious that we support things like RegExp matches, ala String.prototype.match.

@mjackson mjackson changed the title Discussion: expect(object).toInclude(otherObject) - should use tmatch? Add tmatch support to expect(object).toMatch Apr 19, 2016
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

No branches or pull requests

3 participants