mardi 27 janvier 2015

How to test if a set of objects all had the same method called with the same argument in Jasmine 2.0?

Say I have some set of Smurf objects each with a .foo() method, and I also have a SmurfArray that is a normal array with a .foo() method that calls .foo() on each Smurf object it contains. How do I test this behavior in Jasmine 2.0? Ideally I'd want something like:



smurfs = [smurf1, smurf2, smurf3];
smurfArray = makeSmurfArray(smurfs);
smurfArray.foo(7);
expect(smurfs.all.foo).toHaveBeenCalledWith(7);


The Jasmine 2.0 docs are surprisingly difficult to navigate, is this type of thing possible? If so, what's the proper syntax?


Aucun commentaire:

Enregistrer un commentaire