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

contains() should auto-wrap in a matcher #69

Open
tvolkert opened this issue Mar 12, 2018 · 2 comments
Open

contains() should auto-wrap in a matcher #69

tvolkert opened this issue Mar 12, 2018 · 2 comments
Labels
type-enhancement A request for a change that isn't a bug
Milestone

Comments

@tvolkert
Copy link

Use case:

expect(fontManifest, contains({
  'family': 'DummyFont',
  'fonts': [
    {'asset': 'fonts/dummy_font_regular'},
    {'asset': 'fonts/dummy_font_bold', 'weight': 600},
    {'asset': 'fonts/dummy_font_italic', 'style': 'italic'},
    {'asset': 'fonts/dummy_font_bold_italic', 'weight': 600, 'style': 'italic'},
  ],
}));

Right now, this doesn't work, and the user has to explicitly call wrapMatcher() to get the desired behavior:

expect(fontManifest, contains(wrapMatcher({
  'family': 'DummyFont',
  'fonts': [
    {'asset': 'fonts/dummy_font_regular'},
    {'asset': 'fonts/dummy_font_bold', 'weight': 600},
    {'asset': 'fonts/dummy_font_italic', 'style': 'italic'},
    {'asset': 'fonts/dummy_font_bold_italic', 'weight': 600, 'style': 'italic'},
  ],
})));

It'd be more elegant if contains() implicitly called wrapMatcher() if it were matching against a non-string value.

@tvolkert
Copy link
Author

/cc @nex3

@nex3
Copy link
Member

nex3 commented Mar 12, 2018

I believe the reason this doesn't work currently is that contains() is also used to check if a string contains a substring, where wrapping doesn't make sense. But we should be able to call wrapMatcher() on the argument at match-time if the actual value is a collection.

This would technically be a breaking change... we should do it as part of the 1.0.0 refactor.

@nex3 nex3 added this to the 1.0.0 milestone Mar 12, 2018
@nex3 nex3 added the type-enhancement A request for a change that isn't a bug label Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants