vendredi 3 juillet 2015

Jasmine: Spying on Jquery chained selectors

How can I mock/spy on the following chained JQuery code in jasmine 2.0+:

$(".someSelector").map(return this.value).get().join();

This code works in practice (i.e on Google Chrome DevTools)

I have tried spying on $.fn for each of the functions: map and get But I get the following error message when i run the test in Jasmine:

TypeError: $(...).map(...).get is not a function

In essence, I simply want to mock the end result returned values of the Jquery chain. How can I accomplish this?

Aucun commentaire:

Enregistrer un commentaire