I am writing Jasminecode to test some logic Restangular. I want to check that my "Foo" has objectbeen reloaded, so that the method foo.getList()will call GET /fooand return the result
I could check this in two ways. I could add .spyin foo.getList()and return to him the expected results. Alternatively, I can use $HttpBackend.whenGET("/foo")and set the expected results there.
Is this one of the preferred?
I would suggest that it HTTPBackendwould be a better option, as it checks "later" in the logical thread. If I used spy, I could not prove, for example, that my Restangularize did not mess up and tried to resolve a different URL.
However, I look at the inherited tests, and they all use it spy, and since I assume that the person who wrote this code is better than me (they can't be more new to me and then me to Angular). this makes me wonder if there is an advantage to using spyover $httpBackend.
source
share