0

Is there a way to assert that a promise array equals your gold standard, minus ordering? Deep equal fails because the ordering isn't guaranteed - the array is being built asynchronously.

As far as I can tell, CaP doesn't include a ".should.eventually.include.all([])" or anything like that. I don't think I'd be able to check every entry, because then where would the notify(done) be chained?

Ledivin
  • 637
  • 5
  • 18

2 Answers2

0

The Chai Things plugin might help you.

You could for example do something like:

.should.eventually.include.something.that.equals(promiseA);
.should.eventually.include.something.that.equals(promiseB);
.should.eventually.include.something.that.equals(promiseC);
juunas
  • 54,244
  • 13
  • 113
  • 149
0

If I understand your question correctly you should be able to do it like this:

        Promise.all(arrayOfPromises).then(function (results) {
            //so check your results here
            for (var i = 0; i < results.length; i++) {
                results[i].should.have....
            }

           //and the notify(done) is chained after this
        }).should.eventually.notify(done);

I hope that helps.

Jukka Puranen
  • 8,026
  • 6
  • 27
  • 25