ember-cli-custom-assertions-collection
ember-cli-custom-assertions-collection copied to clipboard
arrayContainsAll
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)
What comparison function would you implement for that?
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
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
?
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?
Solution will bubble up during implementation and some real use case ... will start from simple