Closed lobodpav closed 10 years ago
I agree and don't agree in the same time. I assume that array is ordered collection and that is why it check order in which elements presented. In opposite object goes unordered.
Good point. Could you mention that in the doc?
I solved this by
var arrayToCheck = [1, 2, 3];
[3, 2].forEach(function(item) {
arrayToCheck.should.containDeep([item]);
});
but I thought it would be nice if I would not have to write so much boilerplate everywhere in my tests.
Agree, about i can add methods like .containEql and .containDeep that just check existence. Any suggestion about name? (it seems switch for method will be not enough, also i am worry how to make it less confusing)
Yeah, was thinking about a good name too. First I thought I would rename the existing ones to .containEqlOrdered
and .containDeepOrdered
. But hard to say how many people adopted these already.
I think .containEqlOrdered()
and .containDeepOrdered()
make the most sense. If you're looking to check something in a certain order, most of the time you'll do a .equal()
anyway.
I will close this as it already in master (will publish today or at weekend). If you have issues about it, pls create new one in shouldjs/should.js.
These asserts work well:
However, changing order of items causes the assert to fail:
I would expect that the order of items in
.containDeep()
argument does not matter because I want to check if the checked array contains all items in the argument no matter the order.