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

arrayContainsAll #1

Open
SlyDen opened this issue Oct 9, 2015 · 5 comments
Open

arrayContainsAll #1

SlyDen opened this issue Oct 9, 2015 · 5 comments

Comments

@SlyDen
Copy link

SlyDen commented Oct 9, 2015

For use case, like

arr2.forEach(item => {
  assert.arrayContains(arr1, item, "arr1 contains all items from arr2");
});

it is nice to implement simplified form:

arrayContainsAll(arr1, arr2)
@lolmaus
Copy link
Owner

lolmaus commented Oct 9, 2015

What comparison function would you implement for that?

@SlyDen SlyDen changed the title arrayContainsAll :enhancement arrayContainsAll Oct 9, 2015
@SlyDen SlyDen changed the title :enhancement arrayContainsAll arrayContainsAll Oct 9, 2015
@SlyDen
Copy link
Author

SlyDen commented Oct 9, 2015

I would also add an option to provide custom compare function ... e.g. I have complex objects in an array and want to compare them by certain field(s) and others I don't care

@lolmaus
Copy link
Owner

lolmaus commented Oct 9, 2015

Custom compare function is an awesome idea. Might be introduced to quite a few assertions.

On the other hand, if you're using a custom function, why not just do an ad-hoc assertion with assert.ok?

@lolmaus
Copy link
Owner

lolmaus commented Oct 9, 2015

I think a custom compare function makes sense when the assertion is complex (e. g. using a loop under the hood).

E. g. it's useless to introduce a custom compare function to arrayContains, but will still be useful for arrayContainsAll.

What do you think?

@SlyDen
Copy link
Author

SlyDen commented Oct 9, 2015

Solution will bubble up during implementation and some real use case ... will start from simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants